Question: One class per file. Don't create multiple classes in the same .java file Don't use static variables and methods Encapsulation: make sure you protect your
- One class per 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 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
Contents
- Create a NetBeans project with
- App.java
- Person.java
Data
- The application App creates 5 Person objects
- using full-parameter constructor with the data below
- name=Marcus Allen, weight=200, hometown=Upper Marlboro, MD, highSchool=Dr. Henry A. Wise, Jr.
- name=Kyle Alston, weight=180, hometown=Robbinsville, NJ, highSchool=Robbinsville
- name=Troy Apke, weight=220, hometown=Mt. Lebanon, PA, highSchool=Mount Lebanon
- name=Matthew Baney, weight=225, hometown=State College, PA, highSchool=State College
- 5. using the no-parameter constructor
- using full-parameter constructor with the data below
Functionality
App creates 5 objects and displays their data.
The classes
- App
- it has the main method which is the method that Java looks for and runs to start any application
- it creates creates 5 Person objects
- 4 with the full-parameter constructor
- 1 with the no-parameter constructor
- it displays information about each object using the toString() method
- Person
- uses encapsulation
- private attributes
- a get and a set method for each attribute
- has the following attributes
- String name;
- int weight;
- String hometown;
- String highSchool;
- has two constructors
- one with no parameters
- the no-parameter constructor use the following default values
- name = "" (blank, no spaces)
- weight = 0
- hometown = "N/A"
- highSchool = "N/A"
- the no-parameter constructor use the following default values
- one with all the parameters (one for each attribute)
- one with no parameters
- a toString( ) method
- Do not use the scanner class or any other user input request. You application should be self-contained and run without user input.
- uses encapsulation
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
