SlideShare a Scribd company logo
Use Netbeans to copy your last lab (Lab 07) to a new project called Lab08.
Close Lab07.
Work on the new Lab08 project then.
The Student class
A Student is a Person with 3 extra attributes, major, academic year and gpa.
Attributes
String major
String academicYear
double GPA
Constructorsone constructor with no input parameterssince it doesn't have input parameters, use
the default data below
major - IST
academicYear - Sr.
GPA - 3.0
remember to call the constructor of the superclass with no parameters
one constructor with all the parameters
all three parameters from Student, one for each attribute
since this is a subclass, remember to include also the parameters for the superclass
Methods
Get and Set methods (a requirement from encapsulation)
public String toString()
returns this object as a String, i.e., make each attribute a String, concatenate all strings and return
as one String.
toString() is a special method, you will learn more about it in the next lessons
it needs to be public
it needs to have @override notation (on the line above the method itself). Netbeans will suggest
you do it.
important : in the subclass toString, remember to make a call to the superclass toString so that
the resulting String includes
data from the subclass Student
data from the superclass Person
The Person Class
Attributes
String firstName
String lastName
String hometown
String state
Height height
Constructorsone constructor with no input parameterssince it doesn't receive any input values,
you need to use the default values below:
firstName - No
lastName - Name
hometown - N/A
state - N/A
height - use the Height class no parameter constructor
one constructor with three parameters
firstName using the input parameter
lastName using the input parameter
height using the input parameter
use the default values for
hometown - N/A
state - N/A
one constructor with all (five) parameters
one input parameter for each attribute
Methods
Get and Set methods (a requirement from encapsulation)
important:
You should start generating the default get and set methods using NetBeans automatic generator
Then you will change getFirstName and setLastName as specified. getFirstName
returns firstName with the first letter in upper case and the remaining of the String in lower case
getLastName
getHometown
getState
getHeight
setFirstName
setLastName
updates lastName to be all caps (all upper case)
remember to use setLastName in all constructors so the data (the updated lastName) is stored
correctly
setHometown
setState
setHeight
public String toString()
returns this object as a String, i.e., make each attribute a String, concatenate all strings and return
as one String.
toString() is a special method, you will learn more about it in the next lessons
it needs to be public
it needs to have @override notation (on the line above the method itself). Netbeans will suggest
you do it.
regarding state , the toString method will have a similar functionality as App had in the first lab.
if the state attribute is "PA", display the object's attribute name plus the message "is from
Pennsylvania"
if the state attribute is not "PA", display the object's attribute name plus the message "is from
out-of-state"
In short, the toString() method returns all the data from each object as a String
public void initials ( )this method
gets firstName and lastName
extract the initials of each one of them
adds a "." period to each of them
and uses "System.out.println" to display them as one String
public void initials ( int option)
this method overloads public void initials( ) . This means, it has the same name, but a different
number of parameters.
if the value of "option" is 1 gets firstName
extract its initials
adds a "." period to to a String
adds the lastName to this String
and uses "System.out.println" to display the String
if the value of "option" is 2
adds firsName to a String
gets lastName
extract its initials
adds a "." period to it
adds it to the String
and uses "System.out.println" to display the String
The Height class
uses encapsulation
private attributes
get and set methods for each attribute
Attributes
int feet
int inches
Constructorsone constructor with no input parameterssince it doesn't receive any input values,
you need to use the default values below:
feet - 5
feet - 6
one constructor with two parameters
feet using the input parameter
inches using the input parameter
Methodspublic String toString()
returns this object as a String, i.e., make each attribute a String, concatenate all strings and return
as one String.
toString() is a special method, you will learn more about it in the next lessons
it needs to be public
it needs to have @override notation (on the line above the method itself). Netbeans will suggest
you do it.
The 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.
PLEASE PROVIDE ALL CODE FOR APP, PERSON, HEIGHT, STUDENT,
PLAYER(ABSTRACT), FOOTBALLPLAYER, AND SOCCER PLAYER. THE OUTPUT
SHALL BE THE SAME AS PICTURED.
Person { firstName=No, lastName=NAME, hometown=N/A, state=N/A, height=Height { feet =
5 , inches = 6 }} Student { major = I ST , academicYear = S r , GP A = 3.0 } Player { number =
0 , sports=none, gamesplayed = 0 } SoccerPlayer { goals = 0 , yellowCards = 0 , ratings = 0.0 }
Person { firstName=Jillian, lastName=JENNINGS, hometown=Montclair, state=out-of-state,
height=Height { feet=5, inches=7 }} Student { major = Cyber, academicYear = Sr , GPA = 3.5 }
Player { number = 7 , sports=Soccer, gamesPlayed = 10 } Soccerplayer { goals = 5 ,
yellowCards = 2 , ratings = 0.3 } Person { firstName=No, lastName=NAME, hometown=N/A,
state=N/A, height = Height { f feet = 5 , inches = 6 }} Student { major = I ST , academicYear =
Sr , GPA = 3.0 } Player { number = 0 , sports=none, gamesPlayed = 0 } FootballPlayer { yards =
0 , minutes 1 layed = 0 , ratings = 0.0 } Person { firstName=Keaton, lastName=ELLIS,
hometown=State College, state=Pennsylvania, height=Height { feet = 5 , inches=11 }} Student {
major = I ST , academicYear = J r . , GPA = 3.5 } Player { number = 26 , sports = Football,
gamesPlayed = 10 } Footballplayer { y ards = 60 , minutesplayed = 30 , ratings = 5.7 }

More Related Content

PDF
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
PDF
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
PDF
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
PDF
Here are the instructions and then the code in a sec. Please R.pdf
PDF
Object Oriented Solved Practice Programs C++ Exams
PPT
Chapter 4 - Defining Your Own Classes - Part I
PPT
Java căn bản - Chapter4
PPT
basic concepts
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
Inheritance - Creating a Multilevel Hierarchy In this lab- you will s.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Here are the instructions and then the code in a sec. Please R.pdf
Object Oriented Solved Practice Programs C++ Exams
Chapter 4 - Defining Your Own Classes - Part I
Java căn bản - Chapter4
basic concepts

Similar to Use Netbeans to copy your last lab (Lab 07) to a new project called La.pdf (20)

PPTX
Computer programming 2 Lesson 10
PDF
Sharable_Java_Python.pdf
DOCX
Goals1)Be able to work with individual bits in java.2).docx
PDF
Astronomical data analysis by python.pdf
PPT
Refactoring
PDF
ESINF02-JCF.pdfESINF02-JCF.pdfESINF02-JCF.pdf
DOCX
do it in eclips and make sure it compile Goals1)Be able to.docx
DOCX
Ecs 10 programming assignment 4 loopapalooza
PPTX
08 class and object
PDF
I really need some help if I have this right so far. PLEASE CHANG.pdf
PPT
Charcater and Strings.ppt Charcater and Strings.ppt
PPTX
A Details Overview How to Use Typescript Generic Type
PPT
Parameters
PDF
Integration Project Inspection 3
DOCX
SeriesTester.classpathSeriesTester.project SeriesT.docx
PDF
I really need some help if I have this right so far. Please Resub.pdf
PPTX
C++ STL (quickest way to learn, even for absolute beginners).pptx
PPTX
C++ STL (quickest way to learn, even for absolute beginners).pptx
PPTX
The ES Library for JavaScript Developers
PDF
CMSC 350 HOMEWORK 1
Computer programming 2 Lesson 10
Sharable_Java_Python.pdf
Goals1)Be able to work with individual bits in java.2).docx
Astronomical data analysis by python.pdf
Refactoring
ESINF02-JCF.pdfESINF02-JCF.pdfESINF02-JCF.pdf
do it in eclips and make sure it compile Goals1)Be able to.docx
Ecs 10 programming assignment 4 loopapalooza
08 class and object
I really need some help if I have this right so far. PLEASE CHANG.pdf
Charcater and Strings.ppt Charcater and Strings.ppt
A Details Overview How to Use Typescript Generic Type
Parameters
Integration Project Inspection 3
SeriesTester.classpathSeriesTester.project SeriesT.docx
I really need some help if I have this right so far. Please Resub.pdf
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
The ES Library for JavaScript Developers
CMSC 350 HOMEWORK 1

More from ashishgargjaipuri (20)

PDF
Use the foebowing numbers for the population in a smalt cfy for the ye.pdf
PDF
Urn 1 contains 6 red and 4 blue marbles and Urn 2 contains 5 red marbl.pdf
PDF
Upon learning the concept of cost of capital- provide your inputs-tho.pdf
PDF
use Java in eclipse to do the following task- Suppose we want to ext.pdf
PDF
USE CISCO PACKET TRACER PLEASE SHOW STEP BY STEP WITH SCREENSHOTS AND.pdf
PDF
US dollar rising against foreign currencies Which of the following sou.pdf
PDF
Unemployment is measured as A- all teens and adults in the civilian la.pdf
PDF
Upon stimulation by the sympathetic nervous system- the adrenal medull.pdf
PDF
Update the variable newsUpdated to the year 2016 using Date methods-.pdf
PDF
Unlucky- Inc- has bonds outstanding with a current market price of $70.pdf
PDF
University-College Central Admission System 1)Identify and name all.pdf
PDF
uestion 14 An external element is something that can impact productivi.pdf
PDF
Unit 6 Discussion- Membrane and the Cell At The membrane is critical t.pdf
PDF
Una vez que se ha identificado una lista de posibles soluciones- el si.pdf
PDF
unit 5 debugging exercise 5-2 need in Java Tasks The DebugFive2 c.pdf
PDF
ubuy uygulamas veya portalnn deerlendirilmesi ubuy uygulamas veya por.pdf
PDF
Typically- bacterial mRNA transcripts contain (a single-multiple) gene (1).pdf
PDF
Type the program's output Input target - int (input (1)) n- Int (input.pdf
PDF
Two mutually exclusive investment opportunities require an initial inv.pdf
PDF
Two scientists are studying the biodiversity of microbes in the differ.pdf
Use the foebowing numbers for the population in a smalt cfy for the ye.pdf
Urn 1 contains 6 red and 4 blue marbles and Urn 2 contains 5 red marbl.pdf
Upon learning the concept of cost of capital- provide your inputs-tho.pdf
use Java in eclipse to do the following task- Suppose we want to ext.pdf
USE CISCO PACKET TRACER PLEASE SHOW STEP BY STEP WITH SCREENSHOTS AND.pdf
US dollar rising against foreign currencies Which of the following sou.pdf
Unemployment is measured as A- all teens and adults in the civilian la.pdf
Upon stimulation by the sympathetic nervous system- the adrenal medull.pdf
Update the variable newsUpdated to the year 2016 using Date methods-.pdf
Unlucky- Inc- has bonds outstanding with a current market price of $70.pdf
University-College Central Admission System 1)Identify and name all.pdf
uestion 14 An external element is something that can impact productivi.pdf
Unit 6 Discussion- Membrane and the Cell At The membrane is critical t.pdf
Una vez que se ha identificado una lista de posibles soluciones- el si.pdf
unit 5 debugging exercise 5-2 need in Java Tasks The DebugFive2 c.pdf
ubuy uygulamas veya portalnn deerlendirilmesi ubuy uygulamas veya por.pdf
Typically- bacterial mRNA transcripts contain (a single-multiple) gene (1).pdf
Type the program's output Input target - int (input (1)) n- Int (input.pdf
Two mutually exclusive investment opportunities require an initial inv.pdf
Two scientists are studying the biodiversity of microbes in the differ.pdf

Recently uploaded (20)

PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Sports Quiz easy sports quiz sports quiz
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
master seminar digital applications in india
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Insiders guide to clinical Medicine.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
FourierSeries-QuestionsWithAnswers(Part-A).pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Abdominal Access Techniques with Prof. Dr. R K Mishra
GDM (1) (1).pptx small presentation for students
Sports Quiz easy sports quiz sports quiz
O7-L3 Supply Chain Operations - ICLT Program
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Microbial disease of the cardiovascular and lymphatic systems
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Complications of Minimal Access Surgery at WLH
TR - Agricultural Crops Production NC III.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
master seminar digital applications in india
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Insiders guide to clinical Medicine.pdf

Use Netbeans to copy your last lab (Lab 07) to a new project called La.pdf

  • 1. Use Netbeans to copy your last lab (Lab 07) to a new project called Lab08. Close Lab07. Work on the new Lab08 project then. The Student class A Student is a Person with 3 extra attributes, major, academic year and gpa. Attributes String major String academicYear double GPA Constructorsone constructor with no input parameterssince it doesn't have input parameters, use the default data below major - IST academicYear - Sr. GPA - 3.0 remember to call the constructor of the superclass with no parameters one constructor with all the parameters all three parameters from Student, one for each attribute since this is a subclass, remember to include also the parameters for the superclass Methods Get and Set methods (a requirement from encapsulation) public String toString() returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as one String. toString() is a special method, you will learn more about it in the next lessons
  • 2. 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
  • 3. 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()
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. 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()
  • 10. 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
  • 11. 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.
  • 12. PLEASE PROVIDE ALL CODE FOR APP, PERSON, HEIGHT, STUDENT, PLAYER(ABSTRACT), FOOTBALLPLAYER, AND SOCCER PLAYER. THE OUTPUT SHALL BE THE SAME AS PICTURED. Person { firstName=No, lastName=NAME, hometown=N/A, state=N/A, height=Height { feet = 5 , inches = 6 }} Student { major = I ST , academicYear = S r , GP A = 3.0 } Player { number = 0 , sports=none, gamesplayed = 0 } SoccerPlayer { goals = 0 , yellowCards = 0 , ratings = 0.0 } Person { firstName=Jillian, lastName=JENNINGS, hometown=Montclair, state=out-of-state, height=Height { feet=5, inches=7 }} Student { major = Cyber, academicYear = Sr , GPA = 3.5 } Player { number = 7 , sports=Soccer, gamesPlayed = 10 } Soccerplayer { goals = 5 , yellowCards = 2 , ratings = 0.3 } Person { firstName=No, lastName=NAME, hometown=N/A, state=N/A, height = Height { f feet = 5 , inches = 6 }} Student { major = I ST , academicYear = Sr , GPA = 3.0 } Player { number = 0 , sports=none, gamesPlayed = 0 } FootballPlayer { yards = 0 , minutes 1 layed = 0 , ratings = 0.0 } Person { firstName=Keaton, lastName=ELLIS, hometown=State College, state=Pennsylvania, height=Height { feet = 5 , inches=11 }} Student { major = I ST , academicYear = J r . , GPA = 3.5 } Player { number = 26 , sports = Football, gamesPlayed = 10 } Footballplayer { y ards = 60 , minutesplayed = 30 , ratings = 5.7 }