Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the UML diagrams, you can use a UML drawing utility like UMLet. Do NOT use a text editor! You MUST submit the diagram in

For the UML diagrams, you can use a UML drawing utility like UMLet. Do NOT use a text editor! You MUST submit the diagram in any common image format. Do NOT submit a text document or a Word/Open Office doc! Make sure your methods have the EXACT names and parameters as described! You will submit a SINGLE diagram that contains: The class diagram for the Item class The class diagram for the Food class The relationship between them Submit the diagram to Assignment 05: UML

Implement an Item class It should contain the following PRIVATE data: Page 2 of 9 String name (default: (empty String)) double weight (default: 0) It should have the following PUBLIC methods: Constructor that takes no arguments Constructor that takes name and weight (in that order) Getter method: String getName() Getter method: double getWeight() String toString() Override toString() to return a String with the following format: Example: if name = Spoon and weight = 2: Name: Spoon Weight: 2 4 Implement a Food class that inherits from Item It should contain the following PRIVATE data: double heals (default: 0) It should have the following PUBLIC methods: Constructor that takes name, weight, and heals (in that order) Getter method: double getHeals() Page 3 of 9 String toString() Override toString() to return super.toString() + heals: Example: if name = Cheese, weight = 3, and heals = 20: Name: Cheese Weight: 3 Healing Power: 20

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

Students also viewed these Databases questions