SlideShare a Scribd company logo
1 of 12
Download to read offline
Inheritance - Creating a Multilevel Hierarchy
In this lab, you will start to use Inheritance to create a Creating a Multilevel Hierarchy.
Deliverable
A zipped NetBeans project with 7 classes
App
Person
Height
Student
Player
FootballPlayer
SoccerPlayer
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 Player Class ( now an abstract class )
Player is a Student with some extra attributes
Uses encapsulation
Player now is an abstract class because it has an abstract methodpublic abstract double
getRatings( );
an abstract method is an incomplete method that has to be implemented by the subclasses.
Attributes
private int number
private String sports
private gamesPlayed
Constructorsone constructor with no input parameterssince it doesn't receive any input values,
you need to use the default values below:
number - 0
sports - "none"
gamesPlayed - 0
one constructor with all parameters
one input parameter for each attribute
Methods
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.
Get and Set methods
public int getNumber()
public void setNumber(int number)
public String getSports()
public void setSports(String sports)
public int getGamesPlayed()
public void setGamesPlayed(int gamesPlayed)
public abstract getRatings();
The SoccerPlayer Class
SoccerPlayer is a Player with some extra attributes
Uses encapsulation
SoccerPlayer will implement the method getRatings (an abstract method from the superclass
Player)
toString has to include the result of getRatings() too
Attributes
private int goals
private int yellowCards
Constructorsone constructor with no input parameterssince it doesn't receive any input values,
you need to use the default values below:
goals - 0
yellowCards - 0
one constructor with all (two) parameters
one input parameter for each attribute
Methods
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.
should also include the value of getRatings() in the string
Get and Set methods
public int getGoals()
public void setGoals(int goals)
public int getYellowCards()
public void setYellowCards(int yellowCards)
public double getRatings()calculate and return the ratings using this formula:(double) (goals -
yellowCards)/gamesPlayed
the (double) is called casting, forcing the expression that comes afterwards to become a double.
it is necessary to avoid getting 0 as a result because of the precision loss in the division by
integers
if goals or gamesPlayed is 0, return 0 (you need to do this test to avoid the application crashing
in case one of them is 0)
The FootballPlayer Class
FootballPlayer is a Player with some extra attributes
Uses encapsulation
FootballPlayer will implement the method getRatings (an abstract method from the superclass
Player)
toString has to include the result of getRatings() too
Attributes
private int yards
private int minutesPlayed
Constructorsone constructor with no input parameterssince it doesn't receive any input values,
you need to use the default values below:
yards - 0
minutesPlayed - 0
one constructor with all (two) parameters
one input parameter for each attribute
Methods
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.
should also include the value of getRatings() in the string
Get and Set methods
public int getYards()
public void getYards(int yards)
public int getMinutesPlayed()
public void setMinutesPlayed(int minutesPlayed)
public double getRatings()calculate and return the ratings using this formula:(double) ( (yards -
minutesPlayed/10.0) ) /gamesPlayed
be careful with the parenthesis to avoid getting 0 as a result
the (double) is called casting, forcing the expression that comes afterward to become a double.
it is necessary to avoid getting 0 as a result because of the precision loss in the division by
integers
use 10.0 instead of 10 to force Java to use more precision in the calculation
if yards or gamesPlayed is 0, return 0 (you need to do this test to avoid the application crashing
in case one of them is 0)
The App class
create a SoccerPlayer object called sp0 using the no-parameter constructor
create a SoccerPlayer object called sp1 using the all-parameter constructor with the values
goals - 5
yellowCards - 2
number - 7
sports - Soccer
gamesPlayed - 10
major - Cyber
academicYear - Sr.
GPA - 3.5
firstName - jillian (see the different capitalization used to test the get/set methods)
lastName - Jennings
height 5 7
hometown - Montclair
state - NJ
create a FootballPlayer object called fp0 using the no-parameter
create a FootballPlayer object called fp1 using the all-parameter constructor with the values
yards - 60
minutesPlayed -30
number - 26
sports - Football
gamesPlayed - 10
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
display all the data from each object
Output
Important
you need to display each class toString( ) in a separate line.
You can do this by adding a "n" at the end of the string.
In the last toString you will also add a
"==============================================================" String
to close the line.
The output should be similar to
Generate Getters and Setters Select fields to generate getters and setters for: Encapsulate Fields
Cancel Cenerate

More Related Content

Similar to Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf

Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdfICADCMLTPC
 
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
 
CMSC 350 HOMEWORK 1
CMSC 350 HOMEWORK 1CMSC 350 HOMEWORK 1
CMSC 350 HOMEWORK 1HamesKellor
 
Please write this in java using a GUIImplement a class cal.pdf
Please write this in java using a GUIImplement a class cal.pdfPlease write this in java using a GUIImplement a class cal.pdf
Please write this in java using a GUIImplement a class cal.pdfaniarihant
 
Write a class (BasketballTeam) encapsulating the concept of a tea.pdf
Write a class (BasketballTeam) encapsulating the concept of a tea.pdfWrite a class (BasketballTeam) encapsulating the concept of a tea.pdf
Write a class (BasketballTeam) encapsulating the concept of a tea.pdfrozakashif85
 
SeriesTester.classpathSeriesTester.project SeriesT.docx
SeriesTester.classpathSeriesTester.project  SeriesT.docxSeriesTester.classpathSeriesTester.project  SeriesT.docx
SeriesTester.classpathSeriesTester.project SeriesT.docxlesleyryder69361
 
Goals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxGoals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxjosephineboon366
 
Generators & Decorators.pptx
Generators & Decorators.pptxGenerators & Decorators.pptx
Generators & Decorators.pptxIrfanShaik98
 
Refactoring
RefactoringRefactoring
Refactoringnkaluva
 
Question 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docxQuestion 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docxamrit47
 
do it in eclips and make sure it compile Goals1)Be able to.docx
do it in eclips and make sure it compile Goals1)Be able to.docxdo it in eclips and make sure it compile Goals1)Be able to.docx
do it in eclips and make sure it compile Goals1)Be able to.docxjameywaughj
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with JavaJussi Pohjolainen
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3Dillon Lee
 

Similar to Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf (20)

Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
Sharable_Java_Python.pdf
Sharable_Java_Python.pdfSharable_Java_Python.pdf
Sharable_Java_Python.pdf
 
08 class and object
08   class and object08   class and object
08 class and object
 
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
 
CMSC 350 HOMEWORK 1
CMSC 350 HOMEWORK 1CMSC 350 HOMEWORK 1
CMSC 350 HOMEWORK 1
 
Please write this in java using a GUIImplement a class cal.pdf
Please write this in java using a GUIImplement a class cal.pdfPlease write this in java using a GUIImplement a class cal.pdf
Please write this in java using a GUIImplement a class cal.pdf
 
Write a class (BasketballTeam) encapsulating the concept of a tea.pdf
Write a class (BasketballTeam) encapsulating the concept of a tea.pdfWrite a class (BasketballTeam) encapsulating the concept of a tea.pdf
Write a class (BasketballTeam) encapsulating the concept of a tea.pdf
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Computer programming 2 Lesson 10
Computer programming 2  Lesson 10Computer programming 2  Lesson 10
Computer programming 2 Lesson 10
 
SeriesTester.classpathSeriesTester.project SeriesT.docx
SeriesTester.classpathSeriesTester.project  SeriesT.docxSeriesTester.classpathSeriesTester.project  SeriesT.docx
SeriesTester.classpathSeriesTester.project SeriesT.docx
 
basic concepts
basic conceptsbasic concepts
basic concepts
 
Parameters
ParametersParameters
Parameters
 
Goals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxGoals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docx
 
Generators & Decorators.pptx
Generators & Decorators.pptxGenerators & Decorators.pptx
Generators & Decorators.pptx
 
Refactoring
RefactoringRefactoring
Refactoring
 
Question 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docxQuestion 1 1 pts Skip to question text.As part of a bank account.docx
Question 1 1 pts Skip to question text.As part of a bank account.docx
 
do it in eclips and make sure it compile Goals1)Be able to.docx
do it in eclips and make sure it compile Goals1)Be able to.docxdo it in eclips and make sure it compile Goals1)Be able to.docx
do it in eclips and make sure it compile Goals1)Be able to.docx
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
 

More from vishalateen

Iy current wealth is $500 and I have exponential utility- There are tw.pdf
Iy current wealth is $500 and I have exponential utility- There are tw.pdfIy current wealth is $500 and I have exponential utility- There are tw.pdf
Iy current wealth is $500 and I have exponential utility- There are tw.pdfvishalateen
 
its annual payments going to be- How much relief does this provide Del.pdf
its annual payments going to be- How much relief does this provide Del.pdfits annual payments going to be- How much relief does this provide Del.pdf
its annual payments going to be- How much relief does this provide Del.pdfvishalateen
 
it's complete and photos are in seqy characters- now 280 characters)-.pdf
it's complete and photos are in seqy characters- now 280 characters)-.pdfit's complete and photos are in seqy characters- now 280 characters)-.pdf
it's complete and photos are in seqy characters- now 280 characters)-.pdfvishalateen
 
It is very important to label the left and right side of the heart cor.pdf
It is very important to label the left and right side of the heart cor.pdfIt is very important to label the left and right side of the heart cor.pdf
It is very important to label the left and right side of the heart cor.pdfvishalateen
 
It is required to perform factor analysis using SAS on this data 9.pdf
It is required to perform factor analysis using SAS on this data    9.pdfIt is required to perform factor analysis using SAS on this data    9.pdf
It is required to perform factor analysis using SAS on this data 9.pdfvishalateen
 
IT Infrastructure Architecture Infrastructure Building Blocks and Conc (1).pdf
IT Infrastructure Architecture Infrastructure Building Blocks and Conc (1).pdfIT Infrastructure Architecture Infrastructure Building Blocks and Conc (1).pdf
IT Infrastructure Architecture Infrastructure Building Blocks and Conc (1).pdfvishalateen
 
It is a very important criterion for the existence of a valid contract.pdf
It is a very important criterion for the existence of a valid contract.pdfIt is a very important criterion for the existence of a valid contract.pdf
It is a very important criterion for the existence of a valid contract.pdfvishalateen
 
istannad Fer dadt fimn of the citece mid cyt in-During the conyersion.pdf
istannad Fer dadt fimn of the citece mid cyt in-During the conyersion.pdfistannad Fer dadt fimn of the citece mid cyt in-During the conyersion.pdf
istannad Fer dadt fimn of the citece mid cyt in-During the conyersion.pdfvishalateen
 
Issues about the Tax 3- Core Issue(s) Based on the strategic analysis.pdf
Issues about the Tax  3- Core Issue(s) Based on the strategic analysis.pdfIssues about the Tax  3- Core Issue(s) Based on the strategic analysis.pdf
Issues about the Tax 3- Core Issue(s) Based on the strategic analysis.pdfvishalateen
 
is used for media access control in Wi-Fi networks- A) Contention B) C.pdf
is used for media access control in Wi-Fi networks- A) Contention B) C.pdfis used for media access control in Wi-Fi networks- A) Contention B) C.pdf
is used for media access control in Wi-Fi networks- A) Contention B) C.pdfvishalateen
 
Is this correct- Positive tests in the fermentation tests turned the t.pdf
Is this correct- Positive tests in the fermentation tests turned the t.pdfIs this correct- Positive tests in the fermentation tests turned the t.pdf
Is this correct- Positive tests in the fermentation tests turned the t.pdfvishalateen
 
Is there an extinction threat to snow leopards - If so- what is causin.pdf
Is there an extinction threat to snow leopards - If so- what is causin.pdfIs there an extinction threat to snow leopards - If so- what is causin.pdf
Is there an extinction threat to snow leopards - If so- what is causin.pdfvishalateen
 
is the protocol used to communicate over the internet- TCPAP WAN LN VP.pdf
is the protocol used to communicate over the internet- TCPAP WAN LN VP.pdfis the protocol used to communicate over the internet- TCPAP WAN LN VP.pdf
is the protocol used to communicate over the internet- TCPAP WAN LN VP.pdfvishalateen
 
is senstivi A plant manager considers the operational cost per hour of.pdf
is senstivi A plant manager considers the operational cost per hour of.pdfis senstivi A plant manager considers the operational cost per hour of.pdf
is senstivi A plant manager considers the operational cost per hour of.pdfvishalateen
 
is there a linux command that allows me to see all the directories tha.pdf
is there a linux command that allows me to see all the directories tha.pdfis there a linux command that allows me to see all the directories tha.pdf
is there a linux command that allows me to see all the directories tha.pdfvishalateen
 
Is Fraser Mercantile Bank a Ltd Liability Company have a separate Lega.pdf
Is Fraser Mercantile Bank a Ltd Liability Company have a separate Lega.pdfIs Fraser Mercantile Bank a Ltd Liability Company have a separate Lega.pdf
Is Fraser Mercantile Bank a Ltd Liability Company have a separate Lega.pdfvishalateen
 
is a concept where the derived class acquires the attributes of its ba.pdf
is a concept where the derived class acquires the attributes of its ba.pdfis a concept where the derived class acquires the attributes of its ba.pdf
is a concept where the derived class acquires the attributes of its ba.pdfvishalateen
 
is a decentralized routing approach that is used when there are multip.pdf
is a decentralized routing approach that is used when there are multip.pdfis a decentralized routing approach that is used when there are multip.pdf
is a decentralized routing approach that is used when there are multip.pdfvishalateen
 
IQ scores are normally distributed with a mean score of 100 and a stan.pdf
IQ scores are normally distributed with a mean score of 100 and a stan.pdfIQ scores are normally distributed with a mean score of 100 and a stan.pdf
IQ scores are normally distributed with a mean score of 100 and a stan.pdfvishalateen
 
Ironically- small-box retailers like Dollar General owe their growth t (1).pdf
Ironically- small-box retailers like Dollar General owe their growth t (1).pdfIronically- small-box retailers like Dollar General owe their growth t (1).pdf
Ironically- small-box retailers like Dollar General owe their growth t (1).pdfvishalateen
 

More from vishalateen (20)

Iy current wealth is $500 and I have exponential utility- There are tw.pdf
Iy current wealth is $500 and I have exponential utility- There are tw.pdfIy current wealth is $500 and I have exponential utility- There are tw.pdf
Iy current wealth is $500 and I have exponential utility- There are tw.pdf
 
its annual payments going to be- How much relief does this provide Del.pdf
its annual payments going to be- How much relief does this provide Del.pdfits annual payments going to be- How much relief does this provide Del.pdf
its annual payments going to be- How much relief does this provide Del.pdf
 
it's complete and photos are in seqy characters- now 280 characters)-.pdf
it's complete and photos are in seqy characters- now 280 characters)-.pdfit's complete and photos are in seqy characters- now 280 characters)-.pdf
it's complete and photos are in seqy characters- now 280 characters)-.pdf
 
It is very important to label the left and right side of the heart cor.pdf
It is very important to label the left and right side of the heart cor.pdfIt is very important to label the left and right side of the heart cor.pdf
It is very important to label the left and right side of the heart cor.pdf
 
It is required to perform factor analysis using SAS on this data 9.pdf
It is required to perform factor analysis using SAS on this data    9.pdfIt is required to perform factor analysis using SAS on this data    9.pdf
It is required to perform factor analysis using SAS on this data 9.pdf
 
IT Infrastructure Architecture Infrastructure Building Blocks and Conc (1).pdf
IT Infrastructure Architecture Infrastructure Building Blocks and Conc (1).pdfIT Infrastructure Architecture Infrastructure Building Blocks and Conc (1).pdf
IT Infrastructure Architecture Infrastructure Building Blocks and Conc (1).pdf
 
It is a very important criterion for the existence of a valid contract.pdf
It is a very important criterion for the existence of a valid contract.pdfIt is a very important criterion for the existence of a valid contract.pdf
It is a very important criterion for the existence of a valid contract.pdf
 
istannad Fer dadt fimn of the citece mid cyt in-During the conyersion.pdf
istannad Fer dadt fimn of the citece mid cyt in-During the conyersion.pdfistannad Fer dadt fimn of the citece mid cyt in-During the conyersion.pdf
istannad Fer dadt fimn of the citece mid cyt in-During the conyersion.pdf
 
Issues about the Tax 3- Core Issue(s) Based on the strategic analysis.pdf
Issues about the Tax  3- Core Issue(s) Based on the strategic analysis.pdfIssues about the Tax  3- Core Issue(s) Based on the strategic analysis.pdf
Issues about the Tax 3- Core Issue(s) Based on the strategic analysis.pdf
 
is used for media access control in Wi-Fi networks- A) Contention B) C.pdf
is used for media access control in Wi-Fi networks- A) Contention B) C.pdfis used for media access control in Wi-Fi networks- A) Contention B) C.pdf
is used for media access control in Wi-Fi networks- A) Contention B) C.pdf
 
Is this correct- Positive tests in the fermentation tests turned the t.pdf
Is this correct- Positive tests in the fermentation tests turned the t.pdfIs this correct- Positive tests in the fermentation tests turned the t.pdf
Is this correct- Positive tests in the fermentation tests turned the t.pdf
 
Is there an extinction threat to snow leopards - If so- what is causin.pdf
Is there an extinction threat to snow leopards - If so- what is causin.pdfIs there an extinction threat to snow leopards - If so- what is causin.pdf
Is there an extinction threat to snow leopards - If so- what is causin.pdf
 
is the protocol used to communicate over the internet- TCPAP WAN LN VP.pdf
is the protocol used to communicate over the internet- TCPAP WAN LN VP.pdfis the protocol used to communicate over the internet- TCPAP WAN LN VP.pdf
is the protocol used to communicate over the internet- TCPAP WAN LN VP.pdf
 
is senstivi A plant manager considers the operational cost per hour of.pdf
is senstivi A plant manager considers the operational cost per hour of.pdfis senstivi A plant manager considers the operational cost per hour of.pdf
is senstivi A plant manager considers the operational cost per hour of.pdf
 
is there a linux command that allows me to see all the directories tha.pdf
is there a linux command that allows me to see all the directories tha.pdfis there a linux command that allows me to see all the directories tha.pdf
is there a linux command that allows me to see all the directories tha.pdf
 
Is Fraser Mercantile Bank a Ltd Liability Company have a separate Lega.pdf
Is Fraser Mercantile Bank a Ltd Liability Company have a separate Lega.pdfIs Fraser Mercantile Bank a Ltd Liability Company have a separate Lega.pdf
Is Fraser Mercantile Bank a Ltd Liability Company have a separate Lega.pdf
 
is a concept where the derived class acquires the attributes of its ba.pdf
is a concept where the derived class acquires the attributes of its ba.pdfis a concept where the derived class acquires the attributes of its ba.pdf
is a concept where the derived class acquires the attributes of its ba.pdf
 
is a decentralized routing approach that is used when there are multip.pdf
is a decentralized routing approach that is used when there are multip.pdfis a decentralized routing approach that is used when there are multip.pdf
is a decentralized routing approach that is used when there are multip.pdf
 
IQ scores are normally distributed with a mean score of 100 and a stan.pdf
IQ scores are normally distributed with a mean score of 100 and a stan.pdfIQ scores are normally distributed with a mean score of 100 and a stan.pdf
IQ scores are normally distributed with a mean score of 100 and a stan.pdf
 
Ironically- small-box retailers like Dollar General owe their growth t (1).pdf
Ironically- small-box retailers like Dollar General owe their growth t (1).pdfIronically- small-box retailers like Dollar General owe their growth t (1).pdf
Ironically- small-box retailers like Dollar General owe their growth t (1).pdf
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 

Recently uploaded (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 

Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf

  • 1. Inheritance - Creating a Multilevel Hierarchy In this lab, you will start to use Inheritance to create a Creating a Multilevel Hierarchy. Deliverable A zipped NetBeans project with 7 classes App Person Height Student Player FootballPlayer SoccerPlayer 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
  • 2. 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
  • 3. 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
  • 4. 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
  • 5. 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:
  • 6. 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 Player Class ( now an abstract class ) Player is a Student with some extra attributes Uses encapsulation Player now is an abstract class because it has an abstract methodpublic abstract double getRatings( ); an abstract method is an incomplete method that has to be implemented by the subclasses. Attributes private int number private String sports private gamesPlayed Constructorsone constructor with no input parameterssince it doesn't receive any input values, you need to use the default values below: number - 0
  • 7. sports - "none" gamesPlayed - 0 one constructor with all parameters one input parameter for each attribute Methods 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. Get and Set methods public int getNumber() public void setNumber(int number) public String getSports() public void setSports(String sports) public int getGamesPlayed() public void setGamesPlayed(int gamesPlayed) public abstract getRatings(); The SoccerPlayer Class SoccerPlayer is a Player with some extra attributes Uses encapsulation SoccerPlayer will implement the method getRatings (an abstract method from the superclass Player)
  • 8. toString has to include the result of getRatings() too Attributes private int goals private int yellowCards Constructorsone constructor with no input parameterssince it doesn't receive any input values, you need to use the default values below: goals - 0 yellowCards - 0 one constructor with all (two) parameters one input parameter for each attribute Methods 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. should also include the value of getRatings() in the string Get and Set methods public int getGoals() public void setGoals(int goals) public int getYellowCards() public void setYellowCards(int yellowCards)
  • 9. public double getRatings()calculate and return the ratings using this formula:(double) (goals - yellowCards)/gamesPlayed the (double) is called casting, forcing the expression that comes afterwards to become a double. it is necessary to avoid getting 0 as a result because of the precision loss in the division by integers if goals or gamesPlayed is 0, return 0 (you need to do this test to avoid the application crashing in case one of them is 0) The FootballPlayer Class FootballPlayer is a Player with some extra attributes Uses encapsulation FootballPlayer will implement the method getRatings (an abstract method from the superclass Player) toString has to include the result of getRatings() too Attributes private int yards private int minutesPlayed Constructorsone constructor with no input parameterssince it doesn't receive any input values, you need to use the default values below: yards - 0 minutesPlayed - 0 one constructor with all (two) parameters one input parameter for each attribute Methods public String toString() returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as one String.
  • 10. 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. should also include the value of getRatings() in the string Get and Set methods public int getYards() public void getYards(int yards) public int getMinutesPlayed() public void setMinutesPlayed(int minutesPlayed) public double getRatings()calculate and return the ratings using this formula:(double) ( (yards - minutesPlayed/10.0) ) /gamesPlayed be careful with the parenthesis to avoid getting 0 as a result the (double) is called casting, forcing the expression that comes afterward to become a double. it is necessary to avoid getting 0 as a result because of the precision loss in the division by integers use 10.0 instead of 10 to force Java to use more precision in the calculation if yards or gamesPlayed is 0, return 0 (you need to do this test to avoid the application crashing in case one of them is 0) The App class create a SoccerPlayer object called sp0 using the no-parameter constructor create a SoccerPlayer object called sp1 using the all-parameter constructor with the values goals - 5 yellowCards - 2 number - 7
  • 11. sports - Soccer gamesPlayed - 10 major - Cyber academicYear - Sr. GPA - 3.5 firstName - jillian (see the different capitalization used to test the get/set methods) lastName - Jennings height 5 7 hometown - Montclair state - NJ create a FootballPlayer object called fp0 using the no-parameter create a FootballPlayer object called fp1 using the all-parameter constructor with the values yards - 60 minutesPlayed -30 number - 26 sports - Football gamesPlayed - 10 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
  • 12. hometown - State College state - PA display all the data from each object Output Important you need to display each class toString( ) in a separate line. You can do this by adding a "n" at the end of the string. In the last toString you will also add a "==============================================================" String to close the line. The output should be similar to Generate Getters and Setters Select fields to generate getters and setters for: Encapsulate Fields Cancel Cenerate