Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA PLEASE question 1 Write a class called Address that will represent an address. The department will contain the following features: street the name of
JAVA PLEASE
question
Write a class called Address that will represent an address. The department will contain the following features:
street the name of the street, of type String.
city the name of the city, of type String.
zip the zip code, type int.
Added the following constructors to the class:
public AddressString street, String city, int zip the constructor will receive the address details and place them in the attributes. There is no need to check the validity of the parameters. It can be assumed that street and city are strings that represent street and city, and zip represents zip code.
public AddressAddress other copy constructor.
Add getset methods to the class for each of the features and according to the writing conventions we learned.
Write the following methods in the class:
public String toString the method will return a string representing the address in the following format if the address is on Herzl Street, Jerusalem zip code the method will return the string:
Herzl st Jerusalem
public boolean equalsAddress other the method will accept as a parameter an object of type Address and return true if the two addresses the address represented by this and the address represented by other are equal. Two addresses will read equal if they are in the same city, same street and same zip code.
public boolean isInTheSameCityAddress other The method will receive as a parameter an object of type Address and will return true if both addresses the address represented by this and the address represented by other are in the same city.
Question
Write a class called Student that represents a student. The department will contain the following features:
name the name of the student, of type String.
studentNum student number, type int.
studentAddress the student's address, of type Address.
Add the following constructor to the class:
public StudentString name, int num, Address studentAddress the constructor will receive the student details and place them in the attributes. Avoid aliasing! You must copy the received studentAddress parameter.
They also added a copy builder to the department.
Add getset methods to the class for each of the attributes. Also here, avoid aliasing.
Write the following features in the class:
public String toString the method will return the student's information in the following format if the student's name is Yossi, his number is and his address is Herzl Street in Jerusalem, zip code the method will return the string:
Student Yossi,
Srudent's Address: Herzl st Jerusalem
public boolean sameAddressStudent other the method as a Student object parameter and will return true if both students the student represented by this and the student represented by other live at the same address.
public boolean isInTheSameCityStudent other the method as an object parameter of type Student and will return true if both students the student represented by this and the student represented by other live in the same city.
Question
Write a class called WorkPlace that represents a workplace that employs students. The workplace has the following features
worker a student working at the workplace, of type Student. Let's say that only one student works at the workplace.
workPlaceAddress the address of the workplace, of type Address
Add the following constructor to the class
public WorkPlaceStudent worker, Address workPlaceAddress the constructor will receive two parameters and copy them to attributes avoid aliasing
Added getset methods for the attributes to the class, and also prevented aliasing here.
Write the following methods in the class:
public String toString the method will return a string representing the workplace in the following format:
Workplace at Jaffa st Jerusalem
Worker: Student Yossi,
Student's address: Herzl st Jerusalem
public boolean isSameAddressAsWorker the method will return true if the workplace is at the same address where its worker lives.
public boolean isSameCityAsWorker the method will return true if the workplace is in the same city where its worker lives.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started