Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Encapsulation In this lab you will start using eneapsubtian in the Person and in the Height classes. Yau will also create a specint get methad
Encapsulation In this lab you will start using eneapsubtian in the Person and in the Height classes. Yau will also create a specint get methad and s special set method. Deliverable A zpped NetDesns praject with 3 classes - App - Persan. - Height Classes Suggestion: - Use Netbeans to copy your last lab (Lab 04) to a new project called Lab05. - Close Lab04. - Work cn the new Lab05 project then. The Person Class - ises encopsulation - private attributes - get and set methods for each attrilsute 1. Attributes - String firstName - Strang lastNarne - String hametown - String state - Height height 2. Constructbes - ane canatructor with no input parameters. - since it doesn't receive amy input values, you need to use the default values belawr - frstivime - No - EstName-Name - hometown- N/A - state-N/A - height- ase the Height class na parameter conatructor - ane constructor with three parameters - firstNarme asing the input parameter - lastName using the input parameter - beight using the input parameter - tse the default values for - hometown- N/A - state- N/A - arve paratructor with all ifives parameters - cone input parameter for each attribute 3. Methods - Get and Set methods la requirement from encapsulation) - important: - You should start generating the defiult get and set methods using NetQeans sutomatic generntor - Then you wil change getFirst Name and setlast Wame as specitied. - getFirstNarne - returns first Name with the first letter in upper case and the remaining of the String in lower case - Get methods should not charige the value of attributes - In this case it should not chagge/updote the value of firstVarme - getListlvame - gethornetown - getstabe - getheight - setFirstNarne - setLastiame - updates lastName to be all caps (all apper case) - remember to use setLastName in all canstructars so the data (the updated lastName; is stored parrectly - sethometown - setStite - setheight - public String toStringl - returns this object as a String, ie, make ench attribute a String concatenate all strigs and returnas poe String - tuStringll is a special methad, you will learn more about it in the neat lessars - it needs to be public - it needs to have Goverride natatian Gon the line above the methad itself. Netbeans will suggest you da it. - regarding state, the tostring method will have a simiar functionality as App had in the first lab. - if the state attriaute is "PA", display the abject's attribute name plus the message "is from Pennsyhania" - if the state attriaute is nat "PA", dieplay the object's attribute name plus the mesage "is from out-of-state" - In short, the taString0 methad returns all the data from each cbject as a String - public void initisls!) - this method - pets frst Name and last Name - extract the initis of each one of them - addsa:- period to each of them - and uses "System.out.printin" to display them as crie String - public void initisls( int aption) - this method overlosds public void initiabt, This mesns, it hos the same name, bat a different number of parsmeters. - if the value of "aptian" 31 - gets frrstlvarne - extract its initials - adds a "- period to to a String - adds the lastName ta this String. - and uses "Systemautprintlin" to display the String - if the value of "aptian" " 62 - adds fisslarne to a Strire - gets lastName - extract its initials - addsa=- period to it - adds it to the String The Height class - Lses encipsulation. - private attribetes - get and set methods for each attribute- 1. Attributer - int feet - int inches 2. Constructers - ane panstructor with no input parameters - since it doesn't receive any input values, you need to use the defauit values belaw: - fect 5 - feet- 6 ane panstrictor with two parameters - feet using the input parameter - inches using the input parameter 3. Methods - public String taStringld - toStringi / overrides the superclass Object toString[ ? method - toStringl/retums irformation about this dass attrbutes as a String - it returns a formatted String with feet and inches - for instance: 52 The Appclass - create a Person object callied p1 using the five-parameter canatructor with the walues - firsthamre - jillian (see the different capitalization used to test the get/set methods) - batNarne-Jennings - height 57 - hemetown-Montelair - state - NJ 2, create a Person abject calked p2 using the three-parameter constructor with the value - firstWarre - KEATON (see the different capitalization used to test the get/set methods) - batharne-Eilis - height 511 3. create a Person abject called p3 using the no-parameter constructer 4. displayall the data from each abject Output The output should be similar to
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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