Skip to content

Commit

Permalink
lab2
Browse files Browse the repository at this point in the history
  • Loading branch information
tonydattolo committed Jan 18, 2020
1 parent 06a6e58 commit 0ab5290
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 52 deletions.
39 changes: 16 additions & 23 deletions ClassProblems/Class2/One.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,21 @@
import javax.swing.JComponent;
import javax.swing.JFrame;
import java.awt.*;
/**
* strings0 are IMMUTABLE
*/
public class One extends JComponent {

public One {
this.p = new Penguin();
}
public static void main(String[] args) {
JFrame a = new JFrame("Blue pill, or red?");
a.setVisible(true);
a.setSize(500,400);

One b = new One();
// System.out.println(b);
a.add(b);
}

public void paintComponent(Graphics g){
// g.setColor(Color.YELLOW);
// g.fillOval(100, 100, 200, 200);
this.p.draw();
}

public class One extends JComponent {
Penguin p; // define it
public One() { // don't forget the parens
this.p = new Penguin("Tony Danza"); // pass the name
}
public static void main(String[] args) {
JFrame a = new JFrame("Blue pill, or red?");
a.setVisible(true);
a.setSize(500,400);

One b = new One();
a.add(b);
}
public void paintComponent(Graphics g){
this.p.draw(g); // draw has an argument, provide
}
}
43 changes: 14 additions & 29 deletions ClassProblems/Class2/Penguin.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
package ClassProblems.Class2;
import java.awt.*;
/**
* penguin
*/
public class Penguin {

public Penguin(String name) {
this.name = name;
}

private String name = "Tommy Gufano";
String nickname = "The Big Sleazy";
public void talk() {
System.out.println("Howdy" + this.name + " otherwise known as, " + this.nickname);
}
public void draw(Graphics g){
// THis is Lab2
g.setColor(Color.YELLOW);
g.fillOval(100, 100, 200, 200);

}
}


// public class Penguin() {
// String name = "Tommy The Big Sleazy Gufano";
// public void talk() {
// System.out.println("Howdy" + name + " otherwise known as, " + this);
// }
// }

public class Penguin {
public Penguin(String name) {
this.name = name;
}
private String name = "Tommy Gufano";
String nickname = "The Big Sleazy";
public void talk() {
System.out.println("Howdy" + this.name + " otherwise known as, " + this.nickname);
}
public void draw(Graphics g){
g.setColor(Color.YELLOW);
g.fillOval(100, 100, 200, 200);
}
}

0 comments on commit 0ab5290

Please sign in to comment.