SlideShare ist ein Scribd-Unternehmen logo
1 von 7
Inheritance - Extending a class
In this lab you will start using Inheritance to create a new class from an existing one.
Deliverable
A zipped NetBeans project with 4 classes
App
Person
Height
Student
Classes
Suggestion:
Use Netbeans to copy your last lab (Lab 05) to a new project called Lab06.
Close Lab05.
Work on the new Lab06 project then.
The Student class
A Student is a Person with 3 extra attributes, major, academic year and gpa.
Attributes
String major
String academicYear
double GPA
Constructorsone constructor with no input parameterssince it doesn't have input parameters, use
the default data below
major - IST
academicYear - Sr.
GPA - 3.0
remember to call the constructor of the superclass with no parameters
one constructor with all the parameters
all three parameters from Student, one for each attribute
since this is a subclass, remember to include also the parameters for the superclass
Methods
Get and Set methods (a requirement from encapsulation)
public String toString()
returns this object as a String, i.e., make each attribute a String, concatenate all strings and return
as one String.
toString() is a special method, you will learn more about it in the next lessons
it needs to be public
it needs to have @override notation (on the line above the method itself). Netbeans will suggest
you do it.
important : in the subclass toString, remember to make a call to the superclass toString so that
the resulting String includes
data from the subclass Student
data from the superclass Person
The Person Class
Attributes
String firstName
String lastName
String hometown
String state
Height height
Constructorsone constructor with no input parameterssince it doesn't receive any input values,
you need to use the default values below:
firstName - No
lastName - Name
hometown - N/A
state - N/A
height - use the Height class no parameter constructor
one constructor with three parameters
firstName using the input parameter
lastName using the input parameter
height using the input parameter
use the default values for
hometown - N/A
state - N/A
one constructor with all (five) parameters
one input parameter for each attribute
Methods
Get and Set methods (a requirement from encapsulation)
important:
You should start generating the default get and set methods using NetBeans automatic generator
Then you will change getFirstName and setLastName as specified. getFirstName
returns firstName with the first letter in upper case and the remaining of the String in lower case
getLastName
getHometown
getState
getHeight
setFirstName
setLastName
updates lastName to be all caps (all upper case)
remember to use setLastName in all constructors so the data (the updated lastName) is stored
correctly
setHometown
setState
setHeight
public String toString()
returns this object as a String, i.e., make each attribute a String, concatenate all strings and return
as one String.
toString() is a special method, you will learn more about it in the next lessons
it needs to be public
it needs to have @override notation (on the line above the method itself). Netbeans will suggest
you do it.
regarding state , the toString method will have a similar functionality as App had in the first lab.
if the state attribute is "PA", display the object's attribute name plus the message "is from
Pennsylvania"
if the state attribute is not "PA", display the object's attribute name plus the message "is from
out-of-state"
In short, the toString() method returns all the data from each object as a String
public void initials ( )this method
gets firstName and lastName
extract the initials of each one of them
adds a "." period to each of them
and uses "System.out.println" to display them as one String
public void initials ( int option)
this method overloads public void initials( ) . This means, it has the same name, but a different
number of parameters.
if the value of "option" is 1 gets firstName
extract its initials
adds a "." period to to a String
adds the lastName to this String
and uses "System.out.println" to display the String
if the value of "option" is 2
adds firsName to a String
gets lastName
extract its initials
adds a "." period to it
adds it to the String
and uses "System.out.println" to display the String
The Height class
uses encapsulation
private attributes
get and set methods for each attribute
Attributes
int feet
int inches
Constructorsone constructor with no input parameterssince it doesn't receive any input values,
you need to use the default values below:
feet - 5
feet - 6
one constructor with two parameters
feet using the input parameter
inches using the input parameter
Methodspublic String toString()
returns this object as a String, i.e., make each attribute a String, concatenate all strings and return
as one String.
toString() is a special method, you will learn more about it in the next lessons
it needs to be public
it needs to have @override notation (on the line above the method itself). Netbeans will suggest
you do it.
The App class
create a Student object called st1 using the all-parameter constructor with the values
major - Cyber
academicYear - Sr.
GPA - 3.5
firstName - jillian (see the different capitalization used to test the get/set methods)
lastName - Jennings
hometown - Montclair
height - 5 7
state - NJ
create a Student object called st2 using the all-parameter constructor with the value
major - IST
academicYear - Jr.
GPA - 3.5
firstName - KEATON (see the different capitalization used to test the get/set methods)
lastName - Ellis
height - 5 11
hometown - State College
state - PA
create a Student object called st3 using the no-parameter constructor
display all the data from each object
Output
The output should be similar to
Require code for ALL classes listed in addition to any explanation of concepts. Thank you
for your assistance.

Weitere ähnliche Inhalte

Ähnlich wie Inheritance - Extending a class In this lab you will start using Inhe.docx

RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0tutorialsruby
 
Main issues with the following code-Im not sure if its reading the fil.pdf
Main issues with the following code-Im not sure if its reading the fil.pdfMain issues with the following code-Im not sure if its reading the fil.pdf
Main issues with the following code-Im not sure if its reading the fil.pdfaonesalem
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfaromanets
 
Dependency Injection in Spring
Dependency Injection in SpringDependency Injection in Spring
Dependency Injection in SpringASG
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...vekariyakashyap
 
08 class and object
08   class and object08   class and object
08 class and objectdhrubo kayal
 
We will be making 4 classes Main - for testing the code Hi.pdf
 We will be making 4 classes Main - for testing the code Hi.pdf We will be making 4 classes Main - for testing the code Hi.pdf
We will be making 4 classes Main - for testing the code Hi.pdfanithareadymade
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdffreddysarabia1
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02auswhit
 
Ecet 370 Education Organization -- snaptutorial.com
Ecet 370   Education Organization -- snaptutorial.comEcet 370   Education Organization -- snaptutorial.com
Ecet 370 Education Organization -- snaptutorial.comDavisMurphyB81
 
Intro To Scala
Intro To ScalaIntro To Scala
Intro To Scalachambeda
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classemecklenburgstrelitzh
 
CSE 110 - Lab 6 What this Lab Is About  Working wi.docx
CSE 110 - Lab 6 What this Lab Is About  Working wi.docxCSE 110 - Lab 6 What this Lab Is About  Working wi.docx
CSE 110 - Lab 6 What this Lab Is About  Working wi.docxfaithxdunce63732
 

Ähnlich wie Inheritance - Extending a class In this lab you will start using Inhe.docx (20)

RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0
 
Main issues with the following code-Im not sure if its reading the fil.pdf
Main issues with the following code-Im not sure if its reading the fil.pdfMain issues with the following code-Im not sure if its reading the fil.pdf
Main issues with the following code-Im not sure if its reading the fil.pdf
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
 
Dependency Injection in Spring
Dependency Injection in SpringDependency Injection in Spring
Dependency Injection in Spring
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
 
Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
 
08 class and object
08   class and object08   class and object
08 class and object
 
java tutorial 3
 java tutorial 3 java tutorial 3
java tutorial 3
 
We will be making 4 classes Main - for testing the code Hi.pdf
 We will be making 4 classes Main - for testing the code Hi.pdf We will be making 4 classes Main - for testing the code Hi.pdf
We will be making 4 classes Main - for testing the code Hi.pdf
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
 
Lewis jssap3 e_labman02
Lewis jssap3 e_labman02Lewis jssap3 e_labman02
Lewis jssap3 e_labman02
 
Ecet 370 Education Organization -- snaptutorial.com
Ecet 370   Education Organization -- snaptutorial.comEcet 370   Education Organization -- snaptutorial.com
Ecet 370 Education Organization -- snaptutorial.com
 
Intro To Scala
Intro To ScalaIntro To Scala
Intro To Scala
 
Spsl vi unit final
Spsl vi unit finalSpsl vi unit final
Spsl vi unit final
 
Spsl v unit - final
Spsl v unit - finalSpsl v unit - final
Spsl v unit - final
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classe
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
CSE 110 - Lab 6 What this Lab Is About  Working wi.docx
CSE 110 - Lab 6 What this Lab Is About  Working wi.docxCSE 110 - Lab 6 What this Lab Is About  Working wi.docx
CSE 110 - Lab 6 What this Lab Is About  Working wi.docx
 
Lecture3.pdf
Lecture3.pdfLecture3.pdf
Lecture3.pdf
 

Mehr von PeterirMBowerv

In your initial discussion post- consider the following- What do acco.docx
In your initial discussion post- consider the following-  What do acco.docxIn your initial discussion post- consider the following-  What do acco.docx
In your initial discussion post- consider the following- What do acco.docxPeterirMBowerv
 
is based on comparison of processes with a direct adversary in industr.docx
is based on comparison of processes with a direct adversary in industr.docxis based on comparison of processes with a direct adversary in industr.docx
is based on comparison of processes with a direct adversary in industr.docxPeterirMBowerv
 
is the ability to satisfy the unique needs of each customer by changin.docx
is the ability to satisfy the unique needs of each customer by changin.docxis the ability to satisfy the unique needs of each customer by changin.docx
is the ability to satisfy the unique needs of each customer by changin.docxPeterirMBowerv
 
is a rough measure of the entire harmful environmental impacts of indi.docx
is a rough measure of the entire harmful environmental impacts of indi.docxis a rough measure of the entire harmful environmental impacts of indi.docx
is a rough measure of the entire harmful environmental impacts of indi.docxPeterirMBowerv
 
Invertebrates worksheet (except Arthropoda and Chordata)- Part 1- Pori.docx
Invertebrates worksheet (except Arthropoda and Chordata)- Part 1- Pori.docxInvertebrates worksheet (except Arthropoda and Chordata)- Part 1- Pori.docx
Invertebrates worksheet (except Arthropoda and Chordata)- Part 1- Pori.docxPeterirMBowerv
 
INVESTMENT PLANNING 6-Hedgers in the context of futures and options.docx
INVESTMENT PLANNING   6-Hedgers in the context of futures and options.docxINVESTMENT PLANNING   6-Hedgers in the context of futures and options.docx
INVESTMENT PLANNING 6-Hedgers in the context of futures and options.docxPeterirMBowerv
 
Invertebrates are very speciose- beina 95- of all oraanisms- and are o.docx
Invertebrates are very speciose- beina 95- of all oraanisms- and are o.docxInvertebrates are very speciose- beina 95- of all oraanisms- and are o.docx
Invertebrates are very speciose- beina 95- of all oraanisms- and are o.docxPeterirMBowerv
 
In which table is the foreign key placed- Pick Citizen State The tabl.docx
In which table is the foreign key placed-  Pick Citizen State The tabl.docxIn which table is the foreign key placed-  Pick Citizen State The tabl.docx
In which table is the foreign key placed- Pick Citizen State The tabl.docxPeterirMBowerv
 
Introduction to Computer Science Program Assignment 2 Problem 1- A per.docx
Introduction to Computer Science Program Assignment 2 Problem 1- A per.docxIntroduction to Computer Science Program Assignment 2 Problem 1- A per.docx
Introduction to Computer Science Program Assignment 2 Problem 1- A per.docxPeterirMBowerv
 
Intro Four Seasons has preferred stock outstanding that promises to pa.docx
Intro Four Seasons has preferred stock outstanding that promises to pa.docxIntro Four Seasons has preferred stock outstanding that promises to pa.docx
Intro Four Seasons has preferred stock outstanding that promises to pa.docxPeterirMBowerv
 
Intro lecture 1- What is an ecological 'community'- 2- What group of o.docx
Intro lecture 1- What is an ecological 'community'- 2- What group of o.docxIntro lecture 1- What is an ecological 'community'- 2- What group of o.docx
Intro lecture 1- What is an ecological 'community'- 2- What group of o.docxPeterirMBowerv
 
International Human Resource Management Question 1 ) Despite the diffi.docx
International Human Resource Management Question 1 ) Despite the diffi.docxInternational Human Resource Management Question 1 ) Despite the diffi.docx
International Human Resource Management Question 1 ) Despite the diffi.docxPeterirMBowerv
 
In which layer of the TCPnP layers are emaA programs mainly used- Appl.docx
In which layer of the TCPnP layers are emaA programs mainly used- Appl.docxIn which layer of the TCPnP layers are emaA programs mainly used- Appl.docx
In which layer of the TCPnP layers are emaA programs mainly used- Appl.docxPeterirMBowerv
 
In which layer of the TCPNP layers is router or packet switch mainly u.docx
In which layer of the TCPNP layers is router or packet switch mainly u.docxIn which layer of the TCPNP layers is router or packet switch mainly u.docx
In which layer of the TCPNP layers is router or packet switch mainly u.docxPeterirMBowerv
 
Intelligence can be described with varying degrees of specificity- For.docx
Intelligence can be described with varying degrees of specificity- For.docxIntelligence can be described with varying degrees of specificity- For.docx
Intelligence can be described with varying degrees of specificity- For.docxPeterirMBowerv
 
Integrating knowledge is a challenge for OHS practice because Question.docx
Integrating knowledge is a challenge for OHS practice because Question.docxIntegrating knowledge is a challenge for OHS practice because Question.docx
Integrating knowledge is a challenge for OHS practice because Question.docxPeterirMBowerv
 
int -numbers- b) Dynamically create al 2D array of 20 rows and 10 colu.docx
int -numbers- b) Dynamically create al 2D array of 20 rows and 10 colu.docxint -numbers- b) Dynamically create al 2D array of 20 rows and 10 colu.docx
int -numbers- b) Dynamically create al 2D array of 20 rows and 10 colu.docxPeterirMBowerv
 
Instrumental Cognitive Nostalgia Modeling Figurative Question 29 Marke.docx
Instrumental Cognitive Nostalgia Modeling Figurative Question 29 Marke.docxInstrumental Cognitive Nostalgia Modeling Figurative Question 29 Marke.docx
Instrumental Cognitive Nostalgia Modeling Figurative Question 29 Marke.docxPeterirMBowerv
 
In this assignment PPT refers to Pro Poor Tourism CBT means community.docx
In this assignment PPT refers to Pro Poor Tourism CBT means community.docxIn this assignment PPT refers to Pro Poor Tourism CBT means community.docx
In this assignment PPT refers to Pro Poor Tourism CBT means community.docxPeterirMBowerv
 

Mehr von PeterirMBowerv (20)

In your initial discussion post- consider the following- What do acco.docx
In your initial discussion post- consider the following-  What do acco.docxIn your initial discussion post- consider the following-  What do acco.docx
In your initial discussion post- consider the following- What do acco.docx
 
is based on comparison of processes with a direct adversary in industr.docx
is based on comparison of processes with a direct adversary in industr.docxis based on comparison of processes with a direct adversary in industr.docx
is based on comparison of processes with a direct adversary in industr.docx
 
is the ability to satisfy the unique needs of each customer by changin.docx
is the ability to satisfy the unique needs of each customer by changin.docxis the ability to satisfy the unique needs of each customer by changin.docx
is the ability to satisfy the unique needs of each customer by changin.docx
 
is a rough measure of the entire harmful environmental impacts of indi.docx
is a rough measure of the entire harmful environmental impacts of indi.docxis a rough measure of the entire harmful environmental impacts of indi.docx
is a rough measure of the entire harmful environmental impacts of indi.docx
 
Invertebrates worksheet (except Arthropoda and Chordata)- Part 1- Pori.docx
Invertebrates worksheet (except Arthropoda and Chordata)- Part 1- Pori.docxInvertebrates worksheet (except Arthropoda and Chordata)- Part 1- Pori.docx
Invertebrates worksheet (except Arthropoda and Chordata)- Part 1- Pori.docx
 
INVESTMENT PLANNING 6-Hedgers in the context of futures and options.docx
INVESTMENT PLANNING   6-Hedgers in the context of futures and options.docxINVESTMENT PLANNING   6-Hedgers in the context of futures and options.docx
INVESTMENT PLANNING 6-Hedgers in the context of futures and options.docx
 
Invertebrates are very speciose- beina 95- of all oraanisms- and are o.docx
Invertebrates are very speciose- beina 95- of all oraanisms- and are o.docxInvertebrates are very speciose- beina 95- of all oraanisms- and are o.docx
Invertebrates are very speciose- beina 95- of all oraanisms- and are o.docx
 
In which table is the foreign key placed- Pick Citizen State The tabl.docx
In which table is the foreign key placed-  Pick Citizen State The tabl.docxIn which table is the foreign key placed-  Pick Citizen State The tabl.docx
In which table is the foreign key placed- Pick Citizen State The tabl.docx
 
Introduction to Computer Science Program Assignment 2 Problem 1- A per.docx
Introduction to Computer Science Program Assignment 2 Problem 1- A per.docxIntroduction to Computer Science Program Assignment 2 Problem 1- A per.docx
Introduction to Computer Science Program Assignment 2 Problem 1- A per.docx
 
Intro Four Seasons has preferred stock outstanding that promises to pa.docx
Intro Four Seasons has preferred stock outstanding that promises to pa.docxIntro Four Seasons has preferred stock outstanding that promises to pa.docx
Intro Four Seasons has preferred stock outstanding that promises to pa.docx
 
Intro lecture 1- What is an ecological 'community'- 2- What group of o.docx
Intro lecture 1- What is an ecological 'community'- 2- What group of o.docxIntro lecture 1- What is an ecological 'community'- 2- What group of o.docx
Intro lecture 1- What is an ecological 'community'- 2- What group of o.docx
 
International Human Resource Management Question 1 ) Despite the diffi.docx
International Human Resource Management Question 1 ) Despite the diffi.docxInternational Human Resource Management Question 1 ) Despite the diffi.docx
International Human Resource Management Question 1 ) Despite the diffi.docx
 
In which layer of the TCPnP layers are emaA programs mainly used- Appl.docx
In which layer of the TCPnP layers are emaA programs mainly used- Appl.docxIn which layer of the TCPnP layers are emaA programs mainly used- Appl.docx
In which layer of the TCPnP layers are emaA programs mainly used- Appl.docx
 
In which layer of the TCPNP layers is router or packet switch mainly u.docx
In which layer of the TCPNP layers is router or packet switch mainly u.docxIn which layer of the TCPNP layers is router or packet switch mainly u.docx
In which layer of the TCPNP layers is router or packet switch mainly u.docx
 
Intelligence can be described with varying degrees of specificity- For.docx
Intelligence can be described with varying degrees of specificity- For.docxIntelligence can be described with varying degrees of specificity- For.docx
Intelligence can be described with varying degrees of specificity- For.docx
 
Integrating knowledge is a challenge for OHS practice because Question.docx
Integrating knowledge is a challenge for OHS practice because Question.docxIntegrating knowledge is a challenge for OHS practice because Question.docx
Integrating knowledge is a challenge for OHS practice because Question.docx
 
INt 2 (C) 3-0 -.docx
INt 2  (C) 3-0 -.docxINt 2  (C) 3-0 -.docx
INt 2 (C) 3-0 -.docx
 
int -numbers- b) Dynamically create al 2D array of 20 rows and 10 colu.docx
int -numbers- b) Dynamically create al 2D array of 20 rows and 10 colu.docxint -numbers- b) Dynamically create al 2D array of 20 rows and 10 colu.docx
int -numbers- b) Dynamically create al 2D array of 20 rows and 10 colu.docx
 
Instrumental Cognitive Nostalgia Modeling Figurative Question 29 Marke.docx
Instrumental Cognitive Nostalgia Modeling Figurative Question 29 Marke.docxInstrumental Cognitive Nostalgia Modeling Figurative Question 29 Marke.docx
Instrumental Cognitive Nostalgia Modeling Figurative Question 29 Marke.docx
 
In this assignment PPT refers to Pro Poor Tourism CBT means community.docx
In this assignment PPT refers to Pro Poor Tourism CBT means community.docxIn this assignment PPT refers to Pro Poor Tourism CBT means community.docx
In this assignment PPT refers to Pro Poor Tourism CBT means community.docx
 

Kürzlich hochgeladen

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Kürzlich hochgeladen (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

Inheritance - Extending a class In this lab you will start using Inhe.docx

  • 1. Inheritance - Extending a class In this lab you will start using Inheritance to create a new class from an existing one. Deliverable A zipped NetBeans project with 4 classes App Person Height Student Classes Suggestion: Use Netbeans to copy your last lab (Lab 05) to a new project called Lab06. Close Lab05. Work on the new Lab06 project then. The Student class A Student is a Person with 3 extra attributes, major, academic year and gpa. Attributes String major String academicYear double GPA Constructorsone constructor with no input parameterssince it doesn't have input parameters, use the default data below major - IST academicYear - Sr. GPA - 3.0
  • 2. remember to call the constructor of the superclass with no parameters one constructor with all the parameters all three parameters from Student, one for each attribute since this is a subclass, remember to include also the parameters for the superclass Methods Get and Set methods (a requirement from encapsulation) public String toString() returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as one String. toString() is a special method, you will learn more about it in the next lessons it needs to be public it needs to have @override notation (on the line above the method itself). Netbeans will suggest you do it. important : in the subclass toString, remember to make a call to the superclass toString so that the resulting String includes data from the subclass Student data from the superclass Person The Person Class Attributes String firstName String lastName String hometown String state Height height
  • 3. Constructorsone constructor with no input parameterssince it doesn't receive any input values, you need to use the default values below: firstName - No lastName - Name hometown - N/A state - N/A height - use the Height class no parameter constructor one constructor with three parameters firstName using the input parameter lastName using the input parameter height using the input parameter use the default values for hometown - N/A state - N/A one constructor with all (five) parameters one input parameter for each attribute Methods Get and Set methods (a requirement from encapsulation) important: You should start generating the default get and set methods using NetBeans automatic generator Then you will change getFirstName and setLastName as specified. getFirstName returns firstName with the first letter in upper case and the remaining of the String in lower case getLastName getHometown
  • 4. getState getHeight setFirstName setLastName updates lastName to be all caps (all upper case) remember to use setLastName in all constructors so the data (the updated lastName) is stored correctly setHometown setState setHeight public String toString() returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as one String. toString() is a special method, you will learn more about it in the next lessons it needs to be public it needs to have @override notation (on the line above the method itself). Netbeans will suggest you do it. regarding state , the toString method will have a similar functionality as App had in the first lab. if the state attribute is "PA", display the object's attribute name plus the message "is from Pennsylvania" if the state attribute is not "PA", display the object's attribute name plus the message "is from out-of-state" In short, the toString() method returns all the data from each object as a String public void initials ( )this method gets firstName and lastName extract the initials of each one of them
  • 5. adds a "." period to each of them and uses "System.out.println" to display them as one String public void initials ( int option) this method overloads public void initials( ) . This means, it has the same name, but a different number of parameters. if the value of "option" is 1 gets firstName extract its initials adds a "." period to to a String adds the lastName to this String and uses "System.out.println" to display the String if the value of "option" is 2 adds firsName to a String gets lastName extract its initials adds a "." period to it adds it to the String and uses "System.out.println" to display the String The Height class uses encapsulation private attributes get and set methods for each attribute Attributes int feet int inches
  • 6. Constructorsone constructor with no input parameterssince it doesn't receive any input values, you need to use the default values below: feet - 5 feet - 6 one constructor with two parameters feet using the input parameter inches using the input parameter Methodspublic String toString() returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as one String. toString() is a special method, you will learn more about it in the next lessons it needs to be public it needs to have @override notation (on the line above the method itself). Netbeans will suggest you do it. The App class create a Student object called st1 using the all-parameter constructor with the values major - Cyber academicYear - Sr. GPA - 3.5 firstName - jillian (see the different capitalization used to test the get/set methods) lastName - Jennings hometown - Montclair height - 5 7 state - NJ create a Student object called st2 using the all-parameter constructor with the value
  • 7. major - IST academicYear - Jr. GPA - 3.5 firstName - KEATON (see the different capitalization used to test the get/set methods) lastName - Ellis height - 5 11 hometown - State College state - PA create a Student object called st3 using the no-parameter constructor display all the data from each object Output The output should be similar to Require code for ALL classes listed in addition to any explanation of concepts. Thank you for your assistance.