Question: Can someone help me with the Java coding assgiment? We are using Eclipse Thanks so much !! COSC 1174 Java II Lab Chapter 11 Inheritance

Can someone help me with the Java coding assgiment? We are using Eclipse

Thanks so much !!

COSC 1174 Java II Lab

Chapter 11 Inheritance

You are given a UML for a base class named Circle implementing the circle object. Using this base class, you are to implement the base class plus a class named Disk which inherits the Circle class and a Puck class which inherits the Disk class. Using these classes and sub-classes, you will implement Hockey application that tests the Puck class.

Circle

radius

+ Circle() // default constructor for circle; sets radius to 1

+ Circle(r: double) // pass the radius to initialize the circle

+ getRadius() : double

+ setRadius(r: double)

+ area() : double

+ equals(obj: object) : boolean // object passed to class to compare for equality; returns true if equal

+ toString() : String // returns a string that represents the object

Disk

thickness

+ Disk(r:double, t:double) // constructor for Disk class to initialize radius and thickness

+ setThickness(newThickness: double)

+ getThickness() : double

+ volume() : double // returns the volume of the disk (area * thickness)

+ equals(d:object) : Boolean // compares equality of two disks; returns true if equal (same radius and thickness)

+ toString() : String // overrides the toString() method in Circle; display radius and thickness

Create a Puck class that inherits the Disk class. The Puck class should include member variables weight, standard, and youth. The standard and youth variables should be Boolean variables that are set to either true or false depending on the weight of the puck. A standard puck weighs between 5 and 5.5 ounces. A youth puck weighs between 4 and 4.5 ounces. Official hockey pucks, regardless of weight, are one-inch thick with a three-inch diameter. The Puck class should also contain member methods getWeight(), getDivision(), which returns a string stating whether the puck is standard or youth, and equals() and toString(), which override the same methods in the Disk class. Two pucks are equal if they are in the same division (i.e., standard or youth). The Puck constructor should require an argument for weight. Be sure that the constructor initializes other variables to appropriate values as necessary.

Write the UML for the Puck class and submit that in a Word document. Implement a Hockey Java program that tests the Puck class.

Here is the Hockey test application.

/*

* Hockey.java

*/

/**

* The Puck class is tested.

*/

public class Hockey {

public static void main(String[] args) {

Puck youthPuck = new Puck(4);

Puck adultPuck = new Puck(5.5);

System.out.println(youthPuck.getDivision());

System.out.println("The youth puck has weight " + youthPuck.getWeight() + " ounces.");

System.out.println("The youth puck has radius " + youthPuck.getRadius() + " and thickness " + youthPuck.getThickness());

System.out.println(adultPuck.getDivision());

System.out.println("The adult puck has weight " + adultPuck.getWeight() + " ounces.");

System.out.println("The adult puck as radius " + adultPuck.getRadius() + " and thickness " + adultPuck.getThickness());

System.out.println(The two pucks are equal: + youthPuck.equals(adultPuck));

System.out.println(Adult: + adultPuck.toString());

System.out.println(Youth: + youthPuck.toString());

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!