Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Explore the given classes. Implement a getter method on the wasteRobot class with the following method signature public ArrayList-waste> getwasteBin(string wasteType) The method should return

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Explore the given classes. Implement a getter method on the wasteRobot class with the following method signature public ArrayList-waste> getwasteBin(string wasteType) The method should return the proper waste bin based on the passed wasteType. Compare the given wasteType to each of the public static final constants in the waste class to help determine which bin to return. import java.util.* public class WasteRobot private ArrayList trashBin; private ArrayList compostBin; private ArrayList recyclingBin; public WasteRobot() trashBin-new ArrayList- compostBn = new ArrayListWaste>(); recyclingeln = new ArrayListWaste>(); trashBin.add(new Trash("Plastic Bag")); compostBin.add (new Compost ("Banana Peel")); recyclingBin. add(new Recycling("Soda Can")); Implement this! // getwasteBin(String wasteType) public abstract class Waste public static final String TRASH TYPE "trash"; public static final String COMPOST_TYPE"compost"; public static final String RECYCLING_TYPE"recycling"; private String wasteType; private String wasteName; public Waste(String wasteType, String wasteName) this.wasteType wasteType; this.wasteName wasteName; public String getwasteType) return wasteType; public String toString() return wasteType+ ":"wasteName; public class Trash extends Waste public Trash(String wasteName) super(WasteTRASH-TYPE, wasteName); public class Compost extends Waste public Compost (String wasteName) super (Waste.COMPOST TYPE, wasteName): public class Recycling extends Waste public Recycling(String wasteName) super (Waste.RECYCLING TYPE, wasteName)

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