Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions