JAVA1_Instruction_FA2021_LAB7_Accessibility.docx

COSC 1437 – FA LAB7

Note: in the instruction of the lab change “yourLastName” to your last name

TITLE

Inheritance - Access Static Methods from other classes

TIME TO COMPLETE

Two weeks for class 16 weeks – One week for class 8 weeks

HOW TO DO EACH PART

*Change Smith to your last name

*Change JAMES SMITH to your full name

*Change Mary Lane to the name of user

*Write the file name as the first comment line at the top of program

*Write the comments to explain each part of the program

*After running your program, get the picture of the output window from your program with your name on to paste at the bottom of the pseudo-code to turn in

*Step1: Read the requirement of each part, recognize the objects the requirement talk about to make decision which data type classes we need for the project. Create the UML of each data type class

Also, read the requirement to write the pseudo-code or draw the flowchart to determine what step by step you suppose to do in main() of driver class such that the program is qualified to the requirement

*Step2:

-start editor (for example eclipse) create the project with the following project name:

FA2021_LAB7PART1_yourLastName (part 1)

FA2021_LAB7PART2_yourLastName (part 2)

-add data type class (file with extension .java)

Class: FA2021_Person (part1 – parent class)

Class: FA2021_Employee_yourLastName (part1 – child class)

Class: FA2021_StaticMethod_yourLastName (part 2)

-add driver class

Class: FA2021_EmployeeSalaryOneWeek_yourLastName (part1)

Class: FA2021_CarpetInstallationQuote_Smith.java

*Step3: Based on the UML of data type class, write the code of data type class

Based on the pseudo-code or flowchart, write the code of main() in driver class

*Step:4 compile and run the program

*Step5: debug if there are any errors to complete the program

LAB7 PART1 REQUIREMENT

DATA TYPE CLASSES:

class FA2021_Person (super class), class FA2021_Employee_yourLastName (child class)

Inheritance is the technique that allow one class (child class) inherits attributes and methods of another class (super) without redefine. Read the topics at HOW TO DO LAB to learn how to write the child class inheriting from the parent class.

Suppose we have the following class named FA2021_Person (download from eCampus). The class FA2021_Person_yourLastName hold SSnumber (String), lastName (String), firstName (String), address (String), no-argument constructor, parameter constructor, method toString().

Provide the data type class FA2021_Employee_yourLastName (CHILD CLASS) that inherits SSnumber, lastName, firstName, address, constructors, and method toString from the parent class FA2021_Person (PARENT CLASS).

The class FA2021_Employee_yourLastName holds more data members: salary rate (float), Also, method to calculate the salaryOneWeek():

If salary rate < 1000 then use the formula:

Salary one week = salary rate per hour * 40 (hours)

If salary rate > 1000 then use the formula:

Salary one week = salary rate per year / 52 (weeks)

You should provide the no-argument constructor, parameterized constructor of class FA2021_Employee_yourLastname inherit from the no-argument constructor, parameterized construction and toString() from the parent class FA2021_Persion

DRIVER CLASS

Provide the application FA2021_EmployeeSalaryOneWeek_yourLastName that helps to read the information of an employee about SS number, last name, first name, address, salary rate. Then create the object of employee and display the output as below:

FA2021_EmployeeSalaryOneWeek_Smith.java

SALARY OF THE WEEK – JAMES SMITH

---------------------------------------------

SS Number: 643441234

Name: Mary Lane

Address: 123 Abrams Road Dallas TX 75243

Salary Rate: 24.50

Salary in One Week: 980.00

OR

FA2021_EmployeeSalaryOneWeek_Smith.java

SALARY OF THE WEEK – JAMES SMITH

---------------------------------------------

SS Number: 643441234

Name: Mary Lane

Address: 123 Abrams Road Dallas TX 75243

Salary Rate: 55000.00

Salary: 1057.69

LAB7 PART2 REQUIREMENT

Provide the application that helps you to learn how to access the static methods from main()

CLASS WITH STATIC METHODS:

class FA2021_StaticMethod_yourLastName

-Create a class that only contains all the static methods to calculate the area of square, rectangle, triangle, circle, trapezoid, Parallelogram

Formula to calculate the area of shapes:

Square area = side * side

Rectangle area = length * width

Triangle area = (base * height) / 2

Circle area = (radius * radius) * PI

Trapezoid area = (base1 + base2) * height /2

Parallelogram area = base * height

DRIVER CLASS:

Class FA2021_CarpetInstallationQuote_yourLastName

Provide the application for the company Art Carpet Installation that helps the employees of the company to calculate quote of a carpet installation project

First, provide the menu including the list of shapes and allow users to type a number to select a shape. Each project can have more than one shape, either the same type or different shape.

FA2021_CarpetInstallationQuote_Smith.java

ART CARPET INSTALLATION – JAMES SMITH

-----------------------------------------------------

1. Square

2. Rectangle

3. Triangle

4. Circle

5. Trapezoid

6. Parallelogram

0. DONE

For each shape, you should display the message and read the information enough for calculating the area of the selected shape then access static method from the data type class to have its area and build one output line for the selected shape.

The program should allow users to continue to add more shapes to the quote until users select to DONE. The users can select

After getting the area of all rooms, calculate the total of the area and get all the output line then calculate all the carpet cost, materials cost, labor cost, tax and display the quote in the following format:

FA2021_CarpetInstallationQuote_Smith.java

ART CARPET INSTALLATION – JAMES SMITH

PROJECT AT: 123 Walnut Road Dallas TX 75243

-----------------------------------------------------------------

RECTANGLE - Length = 20.56 Width = 8.42 173.12

RECTANGLE - Length = 15.625 Width = 10.0 156.25

TRIANGLE - base = 4.6 Height = 2.3 5.29

CIRCLE - Radius = 3.4 36.32

Sum of area (square feet) 370.97

-----------------------------------------------------------------

Carpet Cost ($2.75 per square feet) 1020.17

Labor ($1.25 per square feet) 463.71

Materials 102.02

Subtotal 1585.90

Tax (8.25%) 130.84

Total charge 1716.74

Hint: Formula to calculate the cost

Carpet cost = area * $ 2.75 per square foot

Material cost = 10% * carpet cost

Labor = $1.25 per square foot

Subtotal = carpet cost + labor + materials cost

Tax = subtotal * 8.25%

Total = subtotal + tax

the carpet cost with the carpet unit price is $2.75/square feet

The labor cost will be calculated: $1.25/per square feet

Material cost: 10% of carpet cost

The tax will be: 8.25% on subtotal

HOW TO TURN IN THE LAB

You should turn in the following files: (yourLastName should be your last name)

PART1

-UML of class FA2021_Person and class FA2021_Employee_yourLastname

-pseudo-code or flowchart of main() in driver class

FA2021_Person.java

FA2021_Employee_yourLastName.java

FA2021_CarpetInstallationQuote_yourLastName.java

FA2021_Person.class

FA2021_Employee_yourLastName.class

FA2021_CarpetInstallationQuote_yourLastName.class

PART 2

-pseudo-code or flowchart of main() in driver class and output picture

FA2021_CarpetInstallationQuote_Smith.java

FA2021_StaticMethod_yourLastName

IF YOU GET ANY PROBLEM TO SUBMIT FILEs .class YOU CAN COMPRESS ALL PROJECT INTO ONE FILE .zip or .rar TO UPLOAD TO eCampus

HOW TO GRADE THE LAB

TOPIC

POINTS

Turn in on time

3

Part1

Data type class inherits from parent class: data members

1

No argument constructor, parameter constructor

2

Method calculate salary

1

Method toString display output – inherit from parent class

1

Inheritance correctly constructor, toString, method calculate salary

2

Read input

1

Create the object

1

Display the output by call method from data type class

1

Output is correct as requested

1

Compile success, qualified requirement, comments

2

Part2

Class with Static methods (6 methods)

3

Menu – handle to redisplay

2

Access static method from other class correctly

3

Calculate area correctly

2

Output as requested – total result correct

2

Compile success, qualified requirement, comments

2

Total scores

30 points