Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Explore the given classes. Implement a method on the WasteRobot class with the method signature public void sortwaste(ArrayList-waste> wasteTosort) This method should take each waste
Explore the given classes. Implement a method on the WasteRobot class with the method signature public void sortwaste(ArrayList-waste> wasteTosort) This method should take each waste object in the ArrayList wastes wasteTosort and add it to the appropriate bin based on its waste type Trash should be put in the trash bin, compost should be put in the compost bin, and recyciling should be put in the recycling bin. import java.util.*; public class WasteRobot private ArrayList trashBin; private ArrayList compostBin; private ArrayList recyclingBin; public WasteRobot (){ trashB1n = new ArrayListWaste>(); compostBin new ArrayList: recyclingBin -new ArrayList; trashBin.add (new Trash( "Plastic Bag")); compostBin.add(new Compost("Banana Peel" recyclingBin.add(new Recycling("Soda Can")); public ArrayList getWasteBin (String wasteType){ if (wasteType.equals (Waste.TRASH_TYPE))1 return trashBin; else if (wasteType.equals (Waste.COMPOST_TYPE))5 return compostBin; else return recyclingBin; ublic 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.wasteTypewasteType; this.wasteNamewasteName; public String getwasteType) return wasteType; public String toString() return wasteType+ ":"wasteName; public class Recycling extends Waste public Recycling(String wasteName) super (WasteRECYCLING-TYPE, wasteName); public class Compost extends Waste public Compost (String wasteName) super (Waste.COMPOST TYPE, wasteName): public class Trash extends Waste public Trash(String wastelame) super (Waste.TRASH TYPE, wasteName)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started