1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
laila [671]
3 years ago
5

Create a class named Person that holds the following fields: two String objects for the person’s first and last name and a Local

Date 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.

Computers and Technology
2 answers:
faust18 [17]3 years ago
7 0

Answer:

Check the explanation

Explanation:

I have added comments in the code for your easy reference.

//Code for this solution

//File: Person.java

import java.time.LocalDate;

//Person class

public class Person {

//Member variables

private String firstName;

private String lastName;

private LocalDate birthDate;

//Paramterized constructors that initializes all the member variables

public Person(String fName, String lName, LocalDate bDate) {

firstName = fName;

lastName = lName;

birthDate = bDate;

}

//Getter methods for each of the member variables

public String getFirstName() {

return firstName;

}

public String getLastName() {

return lastName;

}

public LocalDate getBirthDate() {

return birthDate;

}

}

//File: Couple.java

//Couple class

public class Couple {

//Member variables

private Person person1;

private Person person2;

//Paramterized constructors that initializes all the member variables

public Couple(Person p1, Person p2) {

person1 = p1;

person2 = p2;

}

//Getter methods for each of the member variables

public Person getFirstPerson() {

return person1;

}

public Person getSecondPerson() {

return person2;

}

}

 

//File: Wedding.java

import java.util.Date;

//Wedding class

public class Wedding {

//Member variables

private Date weddingDate;

private Couple couple;

private String location;

//Paramterized constructors that initializes all the member variables

public Wedding(Date date, Couple c, String wedLocation) {

weddingDate = date;

couple = c;

location = wedLocation;

}

//Getter methods for each of the member variables

public Date getWeddingDate() {

return weddingDate;

}

public Couple getCouple() {

return couple;

}

public String getLocation() {

return location;

}

}

//File: TestWedding.java

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.time.LocalDate;

import java.time.format.DateTimeFormatter;

//Test driver class

public class TestWedding {

private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

//Method to display Wedding details - Couple, Location and Wedding date

public static void displayWedding(Wedding w) {

System.out.println("");

System.out.println("=== Wedding details ===");

Person p1 = w.getCouple().getFirstPerson();

Person p2 = w.getCouple().getSecondPerson();

System.out.println(p1.getFirstName() + " " + p2.getLastName() + "(born " + p1.getBirthDate().format(DateTimeFormatter.ISO_DATE) + ")"

+ " weds " + p2.getFirstName() + " " + p2.getLastName() + "(born " + p2.getBirthDate().format(DateTimeFormatter.ISO_DATE) + ")");

System.out.println("ON");

System.out.println( simpleDateFormat.format( w.getWeddingDate()));

System.out.println("AT");

System.out.println(w.getLocation());

}

//Test method - to create Person, Couple and Wedding objects

public static void main(String[] args) throws ParseException {

//Create Person objects

Person p10 = new Person("John", "Howard", LocalDate.of(2000, 10, 1));

Person p11 = new Person("Mary", "Eliza", LocalDate.of(2002, 1, 2));

//Create Couple object with above data

Couple c1 = new Couple(p10, p11);

//Create Wedding Object

Wedding w1 = new Wedding( simpleDateFormat.parse("2019-05-06"), c1, "CountrySide");

//Display Wedding details

displayWedding(w1);

Person p20 = new Person("James", "Howler", LocalDate.of(1999, 5, 1));

Person p21 = new Person("Jenny", "Hertz", LocalDate.of(2005, 4, 25));

Couple c2 = new Couple(p20, p21);

Wedding w2 = new Wedding(simpleDateFormat.parse("2019-10-02"), c2, "Mary Islands");

displayWedding(w2);

}

}

Kindly check the attached image below for the code output.

BabaBlast [244]3 years ago
5 0

Answer:

See explaination

Explanation:

// Person.java

import java.time.LocalDate;

public class Person {

//attributes

private String firstName;

private String lastName;

private LocalDate birthDate;

//constructor initializing all fields

public Person(String firstName, String lastName, LocalDate birthDate) {

this.firstName = firstName;

this.lastName = lastName;

this.birthDate = birthDate;

}

//getter methods

public String getFirstName() {

return firstName;

}

public String getLastName() {

return lastName;

}

public LocalDate getBirthDate() {

return birthDate;

}

//returns a String containing first and last names

public String toString() {

return firstName + " " + lastName;

}

}

// Couple.java

public class Couple {

//Persons getting married

private Person person1;

private Person person2;

//constructor

public Couple(Person person1, Person person2) {

this.person1 = person1;

this.person2 = person2;

}

//getters

public Person getPerson1() {

return person1;

}

public Person getPerson2() {

return person2;

}

}

// Wedding.java

import java.time.LocalDate;

public class Wedding {

//date of wedding

private LocalDate weddingDate;

//Couple getting married

private Couple couple;

//constructor

public Wedding(LocalDate weddingDate, Couple couple) {

this.weddingDate = weddingDate;

this.couple = couple;

}

//getters

public LocalDate getWeddingDate() {

return weddingDate;

}

public Couple getCouple() {

return couple;

}

atOverride

public String toString() {

return couple.getPerson1()+" weds "+couple.getPerson2();

}

}

// TestWedding.java

import java.time.LocalDate;

import java.time.format.DateTimeFormatter;

public class TestWedding {

//method to display details about a wedding

public static void display(Wedding wedding) {

System.out.println("***Wedding***");

System.out.println("Person 1: " + wedding.getCouple().getPerson1());

System.out.println("Person 2: " + wedding.getCouple().getPerson2());

System.out.println("Date: " + wedding.getWeddingDate().format(DateTimeFormatter.ofPattern("dd/MMM/yyyy")));

}

public static void main(String[] args) {

//a DateTimeFormatter object for parsing date from String

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");

//creating Couple 1

Couple c1 = new Couple(new Person("Oliver", "Queen", LocalDate.parse("11/01/1994",formatter)),

new Person("Felicity", "Smoak", LocalDate.parse("10/07/1996",formatter)));

//creating a Wedding

Wedding wedding1=new Wedding(LocalDate.parse("01/09/2019",formatter), c1);

//creating another couple and wedding

Couple c2 = new Couple(new Person("John", "Diggle", LocalDate.parse("01/08/1989",formatter)),

new Person("Lyla", "Michaels", LocalDate.parse("03/07/1990",formatter)));

Wedding wedding2=new Wedding(LocalDate.parse("08/09/2019",formatter), c2);

//displaying both

display(wedding1);

display(wedding2);

}

}

You might be interested in
All of the following changes have created an urgent need for centralization except: Select one: a. The Internet boom inspired bu
kifflom [539]

All of the following changes have created an urgent need for centralization except The number of qualified software programmers and PC repair technicians is dwindling

<h3><u>Explanation:</u></h3>

When the processing tasks are carried out on a centralized server it refers to the Centralization. In this type of architecture all the computer systems will be connected to a single server in which all the computational work are performed. The client machines that are connected to the central server will get the resources for computing from the centralized server.

The main reasons for the purpose of centralization includes the following such as the development in the internet that required many computer networks, the basic functioning of the business in which the needed applications are fed on the intranets, the cost associated in the maintenance of personal computers on the single network.

3 0
3 years ago
XYZ Corp.’s facilities in Nashua, New Hampshire, are two office buildings 400 feet apart, each with its own LAN. To connect the
damaskus [11]

Answer:

a: Twisted pair won't span a 400-foot distance.

Explanation:

The maximum distance that twisted pair cables can support without attenuation is 100 meters which is approximately 328 feet and the two office buildings are 400 feet apart, so it is useless to install a twisted pair cable for such a large distance. A much better option would be to install optic fiber. Though it is a bit expensive but it is the best option in this case.

Hence option (a) is the correct reason for installing an optic fiber cable rather than a twisted pair cable.

6 0
3 years ago
Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems. A. procedural abstract
valentina_108 [34]

Answer:

procedural abstraction

Explanation:

5 0
2 years ago
Which option should you select to ignore all tracked changes in a document? To ignore all tracked changes in a document, you sho
Cloud [144]

Answer:

where is the options

Explanation:

4 0
2 years ago
When you ask the database more complex questions using comparison operators, you are conducting a _____. sort questionnaire quer
Mice21 [21]
The correct answer is known as a "query".

When you ask a lot of complex questions , which uses comparison operators, that is called a query. A query refers to the <span>exact request for </span>data retrieval<span> with the use of database and information systems. </span>
8 0
3 years ago
Other questions:
  • Search the internet for news of a motor vehicle collision in your community involving drugs or alcohol. Keeping in mind that you
    8·1 answer
  • You listened to a song on your computer. did you use hardware or software? explain.
    15·1 answer
  • Which information is considered free for use?
    9·2 answers
  • Try making a character (string) variable and a logical variable . Try creating a variable with a "missing" value NA. You can cal
    11·1 answer
  • What is the difference between digital art and digital design?
    8·1 answer
  • Graphic software task​
    7·1 answer
  • What is a geam in the ggplot2 system?
    5·1 answer
  • Top 5 best comedy or action movies.
    9·2 answers
  • There is a surplus of scientific researchers for a vaccine. This means the demand for this career has
    8·2 answers
  • What types of company functions are aided by ERP?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!