Question
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
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 creating classes
- you will create the FootballPlayer and the Height classes
- Practice on using information hiding
- FootballPlayer and Height will have private attributes and provide get/set methods
- Learn how to create more complex classes
- the FootballPlayer class uses another class, Height as one of its attributes
Deliverables
A zipped Java project according to the How 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 receives all the attributes as parameters and updates the attributes accordingly
- all the classes are required to have an "empty" constructor that receives no parameters but updates all the attributes as needed
- Follow Horstmann's Java Language Coding Guidelines
- Organized in packages (MVC - Model - View Controller)
Contents
- Start with this NetBeans project Download this NetBeans projector create one with
- App.java
- Model
- Model.java
- FootballPlayer.java
- Height.java
Functionality
- The application App creates a Model object
- The Model class
- creates 3 FootballPlayer objects
- compares the height of the three FootballPlayer objects
- displays a message stating who is the tallest
The classes
- App
- it has the main method 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 and compare their heights
- displays the information for the three players as output
- displays a message stating who is taller or if they are of the same height
- Ignore the start-up code comment and please use this requirement.
- make sure you test your application for all the possible cases
- run your program at least 4 times, changing the heights slightly so that you can test all possibilities in your if statements.
- FootballPlayer
- has the following attributes
- int number;
- String name;
- String position;
- Height height;
- int weight;
- String hometown;
- String highSchool;
- has the following attributes
- Height
- it is a class (or type) which is used in FootballPlayer defining the type of the attribute height
- it has two attributes
- int feet;
- int inches
- it also has a method that returns a formatted string with feet and inches
- for instance: 5'2"
- the purpose of this method is to return a string value in this format to be displayed to the user
- Suggestion for improvement and ease of use in height comparisons:
- Define a new get method: getHeightInInches() which returns the total height in inches
NOTE: Be sure to copy/paste the output results of all of your test runs as a comment block in your App.java source code file. Supplying evidence of successful and complete testing of your application is always required.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started