import java.util.Scanner;
class apples{
public static void main (String[] args) {
Coffee CoffeeObject = new Coffee();
CoffeeObject.saying();
}
}
public class Coffee{
private String girlName; (We don't have value here)
public void setName (String name) {
girlName=name;
}
public String getName() {
return girlName;
}
public void saying() {
System.out.printf("Your first gf was %s", getName());
}
}
import java.util.Scanner;
class apples{
public static void main (String[] args) {
Coffee CoffeeObject = new Coffee("Taylor Swift");
CoffeeObject.saying();
}
}
public class Coffee{
private String girlName;
public Coffee(String name) {
girlName=name;
}
public void setName (String name) {
girlName=name;
}
public String getName() {
return girlName;
}
public void saying() {
System.out.printf("Your first gf was %s", getName());
}
}
import java.util.Scanner;
class apples{
public static void main (String[] args) {
Coffee CoffeeObject = new Coffee("Taylor Swift");
Coffee CoffeeObject2 = new Coffee("Selena Gomez");
CoffeeObject.saying(); (Constructor)
CoffeeObject2.saying();
}
}
public class Coffee{
private String girlName;
public Coffee(String name) {
girlName=name;
}
public void setName (String name) {
girlName=name;
}
public String getName() {
return girlName;
}
public void saying() {
System.out.printf("Your first gf was %s\n", getName());
}
}
Comments
Post a Comment