In: Computer Science
This question has already been posted, but the answers are not coming across on my MindTap as correct. I'm hoping somebody can do it differently so that it is accecpted.
Create a class named Person that holds the following fields: two String objects for the person’s first and last name and a LocalDate object for the person’s birthdate. Create a class named Couple that contains two Person objects. Create a class named Wedding for a wedding planner that includes the date of the wedding, the Couple being married, and a String for the location.
Provide constructors for each class that accept parameters for each field, and provide get methods for each field.
Person.java
----
import java.time.LocalDate;
public class Person {
private String firstName;
private String lastName;
private LocalDate birthDate;
Person(String fname, String lname, LocalDate
bdate){
firstName = fname;
lastName = lname;
birthDate = bdate;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public LocalDate getBirthDate() {
return birthDate;
}
}
Couple.java
----
public class Couple {
private Person bride;
private Person groom;
public Couple(Person bride, Person groom) {
this.bride = bride;
this.groom = groom;
}
public Person getBride() {
return bride;
}
public Person getGroom() {
return groom;
}
}
Wedding.java
----
import java.time.LocalDate;
public class Wedding {
private LocalDate weddingDate;
private Couple couple;
private String location;
public Wedding(LocalDate weddingDate, Couple couple,
String location) {
super();
this.weddingDate =
weddingDate;
this.couple = couple;
this.location = location;
}
public LocalDate getWeddingDate() {
return weddingDate;
}
public Couple getCouple() {
return couple;
}
public String getLocation() {
return location;
}
}