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
Classes
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 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
I need code for each class described to produce the listed output alongside any explanations
of concepts, thank you for your assistance!

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
 
Generators & Decorators.pptx
Generators & Decorators.pptxGenerators & Decorators.pptx
Generators & Decorators.pptxIrfanShaik98
 
Refactoring
RefactoringRefactoring
Refactoringnkaluva
 
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
 
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
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docxwilcockiris
 

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
 
Computer programming 2 Lesson 10
Computer programming 2  Lesson 10Computer programming 2  Lesson 10
Computer programming 2 Lesson 10
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
basic concepts
basic conceptsbasic concepts
basic concepts
 
SeriesTester.classpathSeriesTester.project SeriesT.docx
SeriesTester.classpathSeriesTester.project  SeriesT.docxSeriesTester.classpathSeriesTester.project  SeriesT.docx
SeriesTester.classpathSeriesTester.project SeriesT.docx
 
Parameters
ParametersParameters
Parameters
 
Generators & Decorators.pptx
Generators & Decorators.pptxGenerators & Decorators.pptx
Generators & Decorators.pptx
 
Refactoring
RefactoringRefactoring
Refactoring
 
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
 
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
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
 

More from EvanpZjSandersony

It process P1 is allocatod 8Mbs and is using only 3 Mbs of it- Another.pdf
It process P1 is allocatod 8Mbs and is using only 3 Mbs of it- Another.pdfIt process P1 is allocatod 8Mbs and is using only 3 Mbs of it- Another.pdf
It process P1 is allocatod 8Mbs and is using only 3 Mbs of it- Another.pdfEvanpZjSandersony
 
It was already known that invasive species have certain characteristic.pdf
It was already known that invasive species have certain characteristic.pdfIt was already known that invasive species have certain characteristic.pdf
It was already known that invasive species have certain characteristic.pdfEvanpZjSandersony
 
it keeps deleting other things from my table and i keep getting a 1175.pdf
it keeps deleting other things from my table and i keep getting a 1175.pdfit keeps deleting other things from my table and i keep getting a 1175.pdf
it keeps deleting other things from my table and i keep getting a 1175.pdfEvanpZjSandersony
 
Iollowing informat an - Becople were we gived at the begineine dad the.pdf
Iollowing informat an - Becople were we gived at the begineine dad the.pdfIollowing informat an - Becople were we gived at the begineine dad the.pdf
Iollowing informat an - Becople were we gived at the begineine dad the.pdfEvanpZjSandersony
 
is a method for building a classification model classification tree li.pdf
is a method for building a classification model classification tree li.pdfis a method for building a classification model classification tree li.pdf
is a method for building a classification model classification tree li.pdfEvanpZjSandersony
 
Is there a database where I can get the concentration or amount of C-1.pdf
Is there a database where I can get the concentration or amount of C-1.pdfIs there a database where I can get the concentration or amount of C-1.pdf
Is there a database where I can get the concentration or amount of C-1.pdfEvanpZjSandersony
 
Is there any issue you can think of that could lead to a legitimate se.pdf
Is there any issue you can think of that could lead to a legitimate se.pdfIs there any issue you can think of that could lead to a legitimate se.pdf
Is there any issue you can think of that could lead to a legitimate se.pdfEvanpZjSandersony
 
is the deployment stage on the SDLC is where the code is put into prod.pdf
is the deployment stage on the SDLC is where the code is put into prod.pdfis the deployment stage on the SDLC is where the code is put into prod.pdf
is the deployment stage on the SDLC is where the code is put into prod.pdfEvanpZjSandersony
 
Intro The return statistics for two stocks and T-bills are given below.pdf
Intro The return statistics for two stocks and T-bills are given below.pdfIntro The return statistics for two stocks and T-bills are given below.pdf
Intro The return statistics for two stocks and T-bills are given below.pdfEvanpZjSandersony
 
Interview questions for front-end developer- UI developer 1- Write exa.pdf
Interview questions for front-end developer- UI developer 1- Write exa.pdfInterview questions for front-end developer- UI developer 1- Write exa.pdf
Interview questions for front-end developer- UI developer 1- Write exa.pdfEvanpZjSandersony
 
INTERRATER RELIABILITY A N D DIAGNOSTIC ACCURACY OF PELVIC GIRDLE P A.pdf
INTERRATER RELIABILITY A N D DIAGNOSTIC ACCURACY OF PELVIC GIRDLE P A.pdfINTERRATER RELIABILITY A N D DIAGNOSTIC ACCURACY OF PELVIC GIRDLE P A.pdf
INTERRATER RELIABILITY A N D DIAGNOSTIC ACCURACY OF PELVIC GIRDLE P A.pdfEvanpZjSandersony
 
Intel borrowed a floating-rate loan at LIBOR and Microsoft borrowed a.pdf
Intel borrowed a floating-rate loan at LIBOR and Microsoft borrowed a.pdfIntel borrowed a floating-rate loan at LIBOR and Microsoft borrowed a.pdf
Intel borrowed a floating-rate loan at LIBOR and Microsoft borrowed a.pdfEvanpZjSandersony
 
Intellectual property can be protected in a number of ways- In some ca.pdf
Intellectual property can be protected in a number of ways- In some ca.pdfIntellectual property can be protected in a number of ways- In some ca.pdf
Intellectual property can be protected in a number of ways- In some ca.pdfEvanpZjSandersony
 
Internal jugular vein Common carotid artery Subclavian vein Aortic arc.pdf
Internal jugular vein Common carotid artery Subclavian vein Aortic arc.pdfInternal jugular vein Common carotid artery Subclavian vein Aortic arc.pdf
Internal jugular vein Common carotid artery Subclavian vein Aortic arc.pdfEvanpZjSandersony
 
Instructions- Part 3 1- You are writing a C program that will store pa.pdf
Instructions- Part 3 1- You are writing a C program that will store pa.pdfInstructions- Part 3 1- You are writing a C program that will store pa.pdf
Instructions- Part 3 1- You are writing a C program that will store pa.pdfEvanpZjSandersony
 
Instructions- Upload only-java file in blackboard- Mobile phones sho.pdf
Instructions-  Upload only-java file in blackboard-  Mobile phones sho.pdfInstructions-  Upload only-java file in blackboard-  Mobile phones sho.pdf
Instructions- Upload only-java file in blackboard- Mobile phones sho.pdfEvanpZjSandersony
 
Insulin (a peptide hormone) stimulates the uptake glucose blood by act.pdf
Insulin (a peptide hormone) stimulates the uptake glucose blood by act.pdfInsulin (a peptide hormone) stimulates the uptake glucose blood by act.pdf
Insulin (a peptide hormone) stimulates the uptake glucose blood by act.pdfEvanpZjSandersony
 
int Minvalue (vector values) f int min- int i- min - values-at (0)- --.pdf
int Minvalue (vector values) f int min- int i- min - values-at (0)- --.pdfint Minvalue (vector values) f int min- int i- min - values-at (0)- --.pdf
int Minvalue (vector values) f int min- int i- min - values-at (0)- --.pdfEvanpZjSandersony
 
Instructions- You are asked to supply answers to the following questio.pdf
Instructions- You are asked to supply answers to the following questio.pdfInstructions- You are asked to supply answers to the following questio.pdf
Instructions- You are asked to supply answers to the following questio.pdfEvanpZjSandersony
 
Information pertaining to the Hearn Corporation is given below- Total.pdf
Information pertaining to the Hearn Corporation is given below- Total.pdfInformation pertaining to the Hearn Corporation is given below- Total.pdf
Information pertaining to the Hearn Corporation is given below- Total.pdfEvanpZjSandersony
 

More from EvanpZjSandersony (20)

It process P1 is allocatod 8Mbs and is using only 3 Mbs of it- Another.pdf
It process P1 is allocatod 8Mbs and is using only 3 Mbs of it- Another.pdfIt process P1 is allocatod 8Mbs and is using only 3 Mbs of it- Another.pdf
It process P1 is allocatod 8Mbs and is using only 3 Mbs of it- Another.pdf
 
It was already known that invasive species have certain characteristic.pdf
It was already known that invasive species have certain characteristic.pdfIt was already known that invasive species have certain characteristic.pdf
It was already known that invasive species have certain characteristic.pdf
 
it keeps deleting other things from my table and i keep getting a 1175.pdf
it keeps deleting other things from my table and i keep getting a 1175.pdfit keeps deleting other things from my table and i keep getting a 1175.pdf
it keeps deleting other things from my table and i keep getting a 1175.pdf
 
Iollowing informat an - Becople were we gived at the begineine dad the.pdf
Iollowing informat an - Becople were we gived at the begineine dad the.pdfIollowing informat an - Becople were we gived at the begineine dad the.pdf
Iollowing informat an - Becople were we gived at the begineine dad the.pdf
 
is a method for building a classification model classification tree li.pdf
is a method for building a classification model classification tree li.pdfis a method for building a classification model classification tree li.pdf
is a method for building a classification model classification tree li.pdf
 
Is there a database where I can get the concentration or amount of C-1.pdf
Is there a database where I can get the concentration or amount of C-1.pdfIs there a database where I can get the concentration or amount of C-1.pdf
Is there a database where I can get the concentration or amount of C-1.pdf
 
Is there any issue you can think of that could lead to a legitimate se.pdf
Is there any issue you can think of that could lead to a legitimate se.pdfIs there any issue you can think of that could lead to a legitimate se.pdf
Is there any issue you can think of that could lead to a legitimate se.pdf
 
is the deployment stage on the SDLC is where the code is put into prod.pdf
is the deployment stage on the SDLC is where the code is put into prod.pdfis the deployment stage on the SDLC is where the code is put into prod.pdf
is the deployment stage on the SDLC is where the code is put into prod.pdf
 
Intro The return statistics for two stocks and T-bills are given below.pdf
Intro The return statistics for two stocks and T-bills are given below.pdfIntro The return statistics for two stocks and T-bills are given below.pdf
Intro The return statistics for two stocks and T-bills are given below.pdf
 
Interview questions for front-end developer- UI developer 1- Write exa.pdf
Interview questions for front-end developer- UI developer 1- Write exa.pdfInterview questions for front-end developer- UI developer 1- Write exa.pdf
Interview questions for front-end developer- UI developer 1- Write exa.pdf
 
INTERRATER RELIABILITY A N D DIAGNOSTIC ACCURACY OF PELVIC GIRDLE P A.pdf
INTERRATER RELIABILITY A N D DIAGNOSTIC ACCURACY OF PELVIC GIRDLE P A.pdfINTERRATER RELIABILITY A N D DIAGNOSTIC ACCURACY OF PELVIC GIRDLE P A.pdf
INTERRATER RELIABILITY A N D DIAGNOSTIC ACCURACY OF PELVIC GIRDLE P A.pdf
 
Intel borrowed a floating-rate loan at LIBOR and Microsoft borrowed a.pdf
Intel borrowed a floating-rate loan at LIBOR and Microsoft borrowed a.pdfIntel borrowed a floating-rate loan at LIBOR and Microsoft borrowed a.pdf
Intel borrowed a floating-rate loan at LIBOR and Microsoft borrowed a.pdf
 
Intellectual property can be protected in a number of ways- In some ca.pdf
Intellectual property can be protected in a number of ways- In some ca.pdfIntellectual property can be protected in a number of ways- In some ca.pdf
Intellectual property can be protected in a number of ways- In some ca.pdf
 
Internal jugular vein Common carotid artery Subclavian vein Aortic arc.pdf
Internal jugular vein Common carotid artery Subclavian vein Aortic arc.pdfInternal jugular vein Common carotid artery Subclavian vein Aortic arc.pdf
Internal jugular vein Common carotid artery Subclavian vein Aortic arc.pdf
 
Instructions- Part 3 1- You are writing a C program that will store pa.pdf
Instructions- Part 3 1- You are writing a C program that will store pa.pdfInstructions- Part 3 1- You are writing a C program that will store pa.pdf
Instructions- Part 3 1- You are writing a C program that will store pa.pdf
 
Instructions- Upload only-java file in blackboard- Mobile phones sho.pdf
Instructions-  Upload only-java file in blackboard-  Mobile phones sho.pdfInstructions-  Upload only-java file in blackboard-  Mobile phones sho.pdf
Instructions- Upload only-java file in blackboard- Mobile phones sho.pdf
 
Insulin (a peptide hormone) stimulates the uptake glucose blood by act.pdf
Insulin (a peptide hormone) stimulates the uptake glucose blood by act.pdfInsulin (a peptide hormone) stimulates the uptake glucose blood by act.pdf
Insulin (a peptide hormone) stimulates the uptake glucose blood by act.pdf
 
int Minvalue (vector values) f int min- int i- min - values-at (0)- --.pdf
int Minvalue (vector values) f int min- int i- min - values-at (0)- --.pdfint Minvalue (vector values) f int min- int i- min - values-at (0)- --.pdf
int Minvalue (vector values) f int min- int i- min - values-at (0)- --.pdf
 
Instructions- You are asked to supply answers to the following questio.pdf
Instructions- You are asked to supply answers to the following questio.pdfInstructions- You are asked to supply answers to the following questio.pdf
Instructions- You are asked to supply answers to the following questio.pdf
 
Information pertaining to the Hearn Corporation is given below- Total.pdf
Information pertaining to the Hearn Corporation is given below- Total.pdfInformation pertaining to the Hearn Corporation is given below- Total.pdf
Information pertaining to the Hearn Corporation is given below- Total.pdf
 

Recently uploaded

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Recently uploaded (20)

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.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🔝
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

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 Classes 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
  • 2. 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:
  • 3. 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
  • 4. 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
  • 5. 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 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 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:
  • 7. 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
  • 8. 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()
  • 9. 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()
  • 10. 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
  • 11. 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
  • 12. 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 I need code for each class described to produce the listed output alongside any explanations of concepts, thank you for your assistance!