this code is in java. Explore the given classes. Implement a getter method on the WasteRobot class with the following method signature public ArrayList 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. Given Classes : WasteRobotTester.java  import java.util.*; public class WasteRobotTester {     public static void main(String[] args)     {         WasteRobot wallie = new WasteRobot();                  // Your test code.     } } WasteRobot.java import java.util.*; public class WasteRobot {     private ArrayList trashBin;     private ArrayList compostBin;     private ArrayList recyclingBin;     public WasteRobot()      {         trashBin = new ArrayList();         compostBin = new ArrayList();         recyclingBin = new ArrayList();                  trashBin.add(new Trash("Plastic Bag"));         compostBin.add(new Compost("Banana Peel"));         recyclingBin.add(new Recycling("Soda Can"));     }          // Implement this!      // getWasteBin(String wasteType)  } Waste.java 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;     } } Trash.java public class Trash extends Waste {     public Trash(String wasteName)     {         super(Waste.TRASH_TYPE, wasteName);     } } Recycling.java public class Recycling extends Waste {     public Recycling(String wasteName)     {         super(Waste.RECYCLING_TYPE, wasteName);     } } Compost.java public class Compost extends Waste {     public Compost(String wasteName)     {         super(Waste.COMPOST_TYPE, wasteName);     } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

this code is in java.

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.

Given Classes :

WasteRobotTester.java 

import java.util.*;

public class WasteRobotTester
{
    public static void main(String[] args)
    {
        WasteRobot wallie = new WasteRobot();
        
        // Your test code.
    }
}


WasteRobot.java

import java.util.*;

public class WasteRobot
{
    private ArrayList<Waste> trashBin;
    private ArrayList<Waste> compostBin;
    private ArrayList<Waste> recyclingBin;

    public WasteRobot() 
    {
        trashBin = 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"));
    }
    
    // Implement this! 
    // getWasteBin(String wasteType) 

}


Waste.java

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

Trash.java

public class Trash extends Waste
{
    public Trash(String wasteName)
    {
        super(Waste.TRASH_TYPE, wasteName);
    }
}

Recycling.java


public class Recycling extends Waste
{
    public Recycling(String wasteName)
    {
        super(Waste.RECYCLING_TYPE, wasteName);
    }
}

Compost.java

public class Compost extends Waste
{
    public Compost(String wasteName)
    {
        super(Waste.COMPOST_TYPE, wasteName);
    }
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education