1. Engineering
  2. Computer Science
  3. explore the given classes implement a method on the wasterobot...

Question: explore the given classes implement a method on the wasterobot...

Question details

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<Waste> trashBin; private ArrayList<Waste> compostBin; private ArrayList<Waste> recyclingBin; public WasteRobot (){ trashB1n = new ArrayList«Waste>(); compostBin new ArrayList<Waste>: recyclingBin -new ArrayList<Waste>; trashBin.add (new Trash( Plastic Bag)); compostBin.add(new Compost(Banana Peel recyclingBin.add(new Recycling(Soda Can)); public ArrayList<Waste> 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 TYPErecycling 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 (Waste·RECYCLING-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):

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution