Question: 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

 Explore the given classes. Implement a getter method on the wasteRobotclass with the following method signature public ArrayList-waste> getwasteBin(string wasteType) The methodshould return the proper waste bin based on the passed wasteType. Comparethe given wasteType to each of the public static final constants inthe waste class to help determine which bin to return. import java.util.*public class WasteRobot private ArrayList trashBin; private ArrayList compostBin; private ArrayList recyclingBin;

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

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!