Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create four Java classes called Name, Address, Employee, and TestEmployee. The TestEmployee class should implement a main method in which an object of Employee is

Create four Java classes called Name, Address, Employee, and TestEmployee. The TestEmployee class should implement a main method in which an object of Employee is instantiated and its values are printed to the screen. Use the following specific requirements for the files that must be created:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Requirements: Name.java Description: The Name class should be declared as a public class and should meet all the requirements listed below. Its purpose is to store a person's full name (first, middle, and last) as three individual string objects. The class should include a public constructor that initializes the instance variables, which should thereafter remain constant. Therefore, the only other method that should be declared publicis the print method which can be called by other objects to print the values of a Name object to the screen. Modifiers Type Name private String first Variables: Purpose stores the first name in a person's full name stores the middle name in a person's full name stores the last name in a person's full name private String middle private String last Modifiers Parameters Constructors: Implementation initializes all three instance variables in the following manner: public String the First, String theMiddle, String the Last first = the First; middle = theMiddle; last = the Last; Modifiers Return Type Name Parameters private String get First none Methods: Implementation returns the instance variable called first returns the instance variable called middle returns the instance variable called last prints the values of a Name object in the following manner: private String getMiddle none private string get Last none public void print none System.out.print(first + " "); System.out.print (Middle + " "); System.out.println(last ); Requirements: Address.java Description: The Address class should be declared as a public class and should meet all the requirements listed below. Its purpose is to store a person's address (street, city, state, and zip code) as four individual String objects. The class should include a public constructor that initializes the instance variables, which should thereafter remain constant. Therefore, the only other method that should be declared public is the print method which can be called by other objects to print the values of an Address object to the screen. Variables: Modifiers Type Name private String street private String city Purpose stores the street information in a person's address stores the name of the city in a person's address stores the name of the state in a person's address stores the zip code in a person's address as a String private String state private string zip Modifiers Parameters Constructors: Implementation initializes all four instance variables in the following manner: public String the Street, String theCity, String theState, String theZip street = the Street; city = theCity; state = theState; zip = theZip; Modifiers Return Type Name Parameters private String none get Street getCity private String none Methods: Implementation returns the instance variable called street returns the instance variable called city returns the instance variable called state returns the instance variable called zip prints the values of an Address object in the following manner: private String getState none private String getZip none public void print none System.out.print (street + ", System.out.print (city System.out.print (state + " "); System.out.println(zip); Requirements: Employee.java Description: The Employee class should be declared as a public class and should meet all the requirements listed below. Its purpose is to store a person's full name (using the Name class defined in the Chapter 1 assignment sheet), address (using the Address class defined in the Chapter 1 assignment sheet), and social security number (using a string object). The Employee class should include a public constructor that initializes the instance variables, which should thereafter remain constant. Therefore, the only other method that should be declared public is the print method which can be called by other objects to print the values of an Employee object to the screen. Modifiers Type Name private Name name Variables: Purpose stores a person's full name stores a person's address stores a person's social security number as a string object private Address address private String social Modifiers Parameters Constructors: Implementation initializes all three instance variables in the following manner: Ipublic Name theName, Address the Address, String the Social name = theName; address = theAddress; social = the Social; Modifiers Return Type Name Parameters private Name getName none Methods: Implementation returns the instance variable called name returns the instance variable called address returns the instance variable called social prints the values of an Employee object in the following manner: private Address getAddress none private String get social none public void print none name.print(); address.print(); System.out.println(social); Requirements: TestEmployee.java Description: The TestEmployee class should be declared as a public class and should meet all the requirements listed below. The Test Employee class should implement a main method which creates an instance of the Employee class (defined in the Chapter 1 Assignment sheet). The main method should create an Employee object called johnDoe and print its values to the screen. Methods: Return Modifiers Type Name Parameters Implementation Students should already be familiar with how to instantiate objects using constructors. Therefore, the actual implementation code for the main method will not be provided. Students may organize output of data according to their own specifications. However, the main method must perform the following tasks: public void string[] main theArgs static 1. Create an instance of Employee called johnDoe using the following values: . Name: John H. Doe Address: 123 Sunset Boulevard, Beverly Hills, CA, 99999 Social Security Number: 123-45-6789 2. Print johnDoe's values to the screen by calling johnDoe's print method. Output: Output of the main method should be similar to the following: Employee: John H. Doe 123 Sunset Boulevard, Beverly Hills, CA, 99999 123-45-6789

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

Design a training session to maximize learning. page 296

Answered: 1 week ago

Question

Design a cross-cultural preparation program. page 300

Answered: 1 week ago