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 names of 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. Then write a program that creates two Wedding objects and in turn passes each to a method that displays all the details. Save the files as Person.java, Couple.java, Wedding.java, and TestWedding.java.
Hello, my first time being here I actually stuck on this assignment that was given from last week. I'm currently working on the last piece of this assignment I would greatly appreicate to any solutions. Here's the question:
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 names of 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.
Then write a program that creates two Wedding objects and in turn passes each to a method that displays all the details.
Save the files as Person.java, Couple.java, Wedding.java, and TestWedding.java.
Here's what I have so far:
//Person Class
import java.time.LocalDate;
public class Person {
String David;
String Gonzalez;
LocalDate September161994;
{
System.out.println(" First Name " + David);
System.out.println(" Last Name " + Gonzalez);
}
public static void main(String[] args)
{
}
}
-------------------
// Couple Class
public class Couple {
String David;
String Sue;
{
System.out.println(" His name is " + David);
System.out.println(" Her name is " + Sue);
}
public static void main(String[] args)
{
}
}
---------------------
// Wedding Class
import java.time.LocalDate;
//Wedding class
public class Wedding {
private static LocalDate weddingDate;
//Member variables
private String c;
private String location;
private LocalDate date;
{
}
//These will Paramterized constructors that initializes all the member variables
public Wedding(LocalDate day, String couple, String wedLocation)
{
date = day;
c = couple;
location = wedLocation;
}
//Getter methods for each of the member variables
public LocalDate getWeddingDate() {
return date;
}
public String getCouple() {
return c;
}
public String getLocation() {
return location;
}
public static void main(String[] args)
{
LocalDate dateObject = LocalDate.of(2019, 11, 9);
Wedding wedding = new Wedding(dateObject, "SantaFe", "New Mexico");
String wedLocation = "Test";
wedLocation = wedding.getLocation();
System.out.println("The Wedding will be held at " + wedLocation);
}
}
---------------------
//TestWedding Class
import java.time.LocalDate;
public class Main
{
public static void main(String[] args) {
Person man1 = new Person("David", "Gonzalez", LocalDate.parse("1994-09-16"));
Person woman1 = new Person("Sue", "Ling", LocalDate.parse("1996-05-12"));
Person man2 = new Person("David", "Johnson", LocalDate.parse("1991-04-13"));
Person woman2 = new Person("Daisy", "Smith", LocalDate.parse("1997-12-01"));
Couple cpl1 = new Couple(man1, woman1);
Couple cpl2 = new Couple(man2, woman2);
Wedding wed1 = new Wedding(cpl1, "New Mexico", LocalDate.parse("2020-09-12"));
Wedding wed2 = new Wedding(cpl2, "Hawaii", LocalDate.parse("2021-01-02"));
displayDetails(wed1, wed2);
}
public static void displayDetails(Wedding w1, Wedding w2) {
System.out.println(w1.toString());
System.out.println(w2.toString());
}
}
I will leave my further email contact in case I don't get a notification here. starrich55@gmail.com
Trending now
This is a popular solution!
Step by step
Solved in 6 steps with 1 images