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
You discover memory is corrupted, what would be an indication of a software vs. a hardware issue?
bearhunter [10]
Hey there!

Memory (RAM) is considered to be hardware since it is a physical component that makes up the computer and is accessed through the CPU rather than internal code that makes the computer run (which is software). Therefore, if you are having issues with the memory, it is likely a problem with a memory chip, making it a hardware issue. 

Hope this helped you out! :-)
8 0
3 years ago
Any1??<br> Write the names of atleast 22 high-level programming languages
Brums [2.3K]

Answer:

1 Array languages

2 Assembly languages

3 Authoring languages

4 Constraint programming languages

5 Command line interface languages

6 Compiled languages

7 Concurrent languages

8 Curly-bracket languages

9 Dataflow languages

10 Data-oriented languages

11 Decision table languages

12 Declarative languages

13 Embeddable languages

13.1 In source code

13.1.1 Server side

13.1.2 Client side

13.2 In object code

14 Educational languages

15 Esoteric languages

16 Extension languages

17 Fourth-generation languages

18 Functional languages

18.1 Pure

18.2 Impure

19 Hardware description languages

19.1 HDLs for analog circuit design

19.2 HDLs for digital circuit design

20 Imperative languages

21 Interactive mode languages

22 Interpreted languages

23 Iterative languages

Explanation:

8 0
2 years ago
With which game is shigeru miyamoto associated
Juliette [100K]

Answer: Mario, Donkey Kong, and Legend of Zelda.

To be honest those are not the only games that Shigeru Miyamoto is associated with, but these are the games that he is most known for. Shigeru Miyamoto is a video game designer and producer who works for the Nintendo company.

These games mentioned are just some of the games that he helped produce for the company. He started working for the Nintendo company on 1977 and helped with the production of multiple games after joining the company. He initially started working in the Nintendo company as a manga artist, but then moved on to help design and produce different video games.

4 0
3 years ago
True or false: pinhole cameras can be outfitted with very accurate viewfinders
arsen [322]

Answer:

true

Explanation:

4 0
2 years ago
Read 2 more answers
Can someone tell me 5 facts about Registers and RAM, please?
Maslowich

\int\limits^a_b {x} \, dx \left \{ {{y=2} \atop {x=2}} \right.  \lim_{n \to \infty} a_n \neq \neq \geqAnswer:

A register is a temporary storage area built into a CPU. ... The instruction register fetches instructions from the program counter (PC) and holds each instruction as it is executed by the processor. The memory registers are used to pass data from memory to the processor.

PLS MARK BRAINLIEST!!!

PLEASE

:

3 0
2 years ago
Other questions:
  • When a cache block has been modified since being read from main memory?
    10·2 answers
  • Cryptolocker is an example of what type of malware?
    11·1 answer
  • If a friend changes the password on your phone how do you get into it if you dont know the password
    12·1 answer
  • A blank is a copy of one or more files that is made in case the original become lost or damaged
    7·1 answer
  • You’re creating a table for one of your slides, and need to make some modifications to your table structure. Which of the follow
    6·2 answers
  • Which of these are forms of data? Check all that apply.
    8·2 answers
  • Name the functional arms of MSDE.
    13·1 answer
  • The data-mining technique that creates a report or visual representation is _____.
    13·1 answer
  • The physical layer of the OSI model is not foundational to any of the other layers. True or False
    8·1 answer
  • 1)What is the hydropower resources/energy?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!