Math 1342 – Calc 2 – Homework Chapter XXXXXXXXXXNAME:________________
Math 1342 – Calc 2 – Homework Chapter XXXXXXXXXXNAME:________________
§4.1 Approximating Polynomials #1-3, 7-11, 15, 16, 20
Math 1342 – Calc 2 – Homework Chapter XXXXXXXXXXNAME:________________
Math 1342 – Calculus XXXXXXXXXXHomework Ch XXXXXXXXXXNAME:_______________________
4.3 E
or in Approximation (1st day) #1, 2, 5, 13, 21
Math 1342 – Calculus XXXXXXXXXXHomework Ch XXXXXXXXXXNAME:_______________________
After reading allL02content pages inLesson 02: Inheritance and Interfaces,you will complete thisassignment according to the information below.
Do not use the scanner class or any other user input request. You application should be self-contained and run without user input.
Assignment Objectives
Practice on implementing inheritance in Java
FootballPlayer will extend a new class, Person
Ove
iding methods
toString( )(Links to an external site.)which is a method from the Object class, will be implemented in OffensiveLine, FootballPlayer, Person and Height
Keep working with more complex classes
in the same way that FootballPlayer had a class as an attribute (Height height), OffensiveLine will have FootballPlayer as an attribute
Deliverables
A zipped Java project according to theHow to submit Labs and Assignments guide.
O.O. Requirements (these items will be part of your grade)
One class, one file. Don't create multiple classes in the same .java file
Don't use static variables and methods
Encapsulation:make sure you protect your class variables and provide access to them through get and set methods
All the classes are required to have a constructor that receivesallthe attributes as parameters and update the attributes accordingly
All theclasses are required to have an "empty" constructor that receivesnoparameters but updates all the attributes as needed
FollowHorstmann's Java Language Coding Guidelines
Organized in packages (MVC - Model - View Controller)
Contents
L02_Description.png
Create a Netbeans project (or keep developing from your previous lab) with
App.java
Model
Model.java
FootballPlayer.java
Height.java
Person.java
OffensiveLine.java
Functionality
The application App creates a Model object
The Model class
creates 3 FootballPlayer objects
creates an OffensiveLine object using the 3FootballPlayer objects
displays information about the OffensiveLine object and its 3 players
it is arequirementthat this should be done using thetoString( )method in OffensiveLine, which will usetoString( )in FootballPlaye
displays the average height of the OffensiveLine
this will be done using the averageHeight in the OffensiveLine
The classes
App
it has themainmethod which is the method that Java looks for and runs to start any application
it creates an object (an instance) of the Model class
Model
this is the class where all the action is going to happen
it creates three football players
it creates an OffensiveLine object using the three players
displays information about the OffensiveLine
this has to be done using the OffensiveLine object
this is really information about its 3 players
the format is free as long as it contains all the information about each of the 3 players
displays the average height of the OffensiveLine
this has to be done using the OffensiveLine object
this has to call the averageHeight method in OffensiveLine
Person
has the following attributes
String name;
Height height;
int weight;
String hometown;
String highSchool;
and a method
String toString( )
toString( ) ove
ides the superclass Object toString( ) method
toString( ) returns information about this class attributes as a String
encapsulation
if you want other classesin the same packageyo have access to the attributes, you need to make themprotectedinstead ofprivate.
see morehere.
FootballPlaye
has the following attributes
int number;
String position;
and a method
String toString( )
toString( ) ove
ides the superclass Object toString( ) method
toString( ) returns information about this class attributes as a String
Height
it is a class (or type) which is used in Person defining the type of the attributeheight
it has two attributes
int feet;
int inches
and a method
String toString( )
toString( ) ove
ides the superclass Object toString( ) method
toString( ) returns information about this class attributes as a String
it returns a formatted string with feet and inches
for instance: 5'2"
OffensiveLine
has the following attributes
FootballPlayer center;
FootballPlayer offensiveGuard;
FootballPlayer offensiveTackle;
They might also be stored in an A
ayList
and two methods
String toString( )
toString( ) ove
ides the superclass Object toString( ) method
toString( ) returns information about the 3 players attributes as a String
int averageHeight()
calculates and returns the average height of the OffensiveLine.
it is calculated based on the height of each of its player