Sorry, I am very new to programming for university. This is a practise question for our test and is set up on code runner. The entire main method and all the classes, methods, constructors and variables were already give to me and I have to make the shown class to print out what I have written. But Bride.getAge()
and Location.getSuburb()
in the println
will not work. Do I need to add something else in?
public class Location {
public static void main(String[] args) {
Bride person = new Bride("Amy Cronos", 29);
Location place = new Location("Tonsley", "South Rd");
Wedding wed = new Wedding(person,place);
show(wed);
}
public static void show(Wedding wed){
System.out.println("Wedding data:" );
System.out.println("Bride: " + wed.getBride() + ", age: " + Bride.getAge);
System.out.println("Location: " + wed.getPlace() + ", suburb: " + Location.getSuburb());
}
private String suburb;
private String street;
Location(String suburb, String street){
this.suburb = suburb;
this.street = street;
}
public String getSuburb(){
return suburb;
}
public String getStreet(){
return street;
}
public class Bride {
private String name;
private int age;
Bride(String name, int age){
this.name = name;
this.age = age;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
}
public class Wedding {
private Bride person;
private Location place;
Wedding(Bride person, Location place){
this.person = person;
this.place = place;
}
public Bride getPerson(){
return person;
}
public Location getPlace(){
return place;
}
}
}