Question: This assignment has to be done in java using any IDE Create a Java class hierarchy to represent weights in tons, pounds and ounces using

This assignment has to be done in java using any IDE
 This assignment has to be done in java using any IDE
Create a Java class hierarchy to represent weights in tons, pounds and

Create a Java class hierarchy to represent weights in tons, pounds and ounces using the UML diagrams below. Create abstract class Weight and classes Weight1, Weight2. blecT> Ounces(): convert int tcompareTo (other: T: int Weight1 tons: int ds: int +Weight10 +Weight1(t: int, p: int) +Weight1(w: Weight1) +setPounds(p: int): void +setTons(t: int): void getPounds): int getTons): int tadd(w: Weight1): Weight1 +subtract (w: Weight1): Weight1 +toounces): int +convert(): void +tostring): String compareTo(W: Weightl): int Weight2 ounces: int +Weight2) +Weight2(t: int, p: int, oz: int) +Weight2(w: Weight2) +setOunces (oz: int) void getounces(): int +add(w: Weight2): Weight2 +subtract(w: Weight2): Weight2 +toounces(): int +convert(): void +tostring String +compareTo(w: Weight2): int Method Notes e add and subtract0 are invoked as a.add(b) and a.subtract(b). Both add0 and subtract() must return Weightls or Weight2s that have been converted e toOunces) returns the this object as a measurement in ounces convert()crts this into a form where the number of pounds is greater than or equal to 0 and less than 2000, number of ounces is greater than or equal to 0 and less than 16 e You can add extra methods if needed or exclude an inherited method that is not overridden

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!