Answered step by step
Verified Expert Solution
Link Copied!

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

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

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

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

5. Identify three characteristics of the dialectical approach.

Answered: 1 week ago

Question

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago