package apples;
public class apples {
private String name;
private cup birthday;
public apples(String theName, cup theDate) {
name = theName;
birthday = theDate;
}
public String toString() {
return String.format("My name is %s, My birthday is %s",name, birthday);
}
}
package apples;
public class cup {
private int month;
private int day;
private int year;
public cup (int m, int d, int y) {
month =m;
day =d;
year = y;
System.out.printf("the constructor for this is %s\n",this);
}
public String toString() {
return String.format("%d/%d/%d",month,day,year);
}
}
package apples;
public class boy {
public static void main (String []args) {
cup cupObject = new cup(4,5,6);
apples applesObject = new apples("Greg", cupObject);
System.out.println(applesObject);
}
}
Comments
Post a Comment