It's 2020. The mentors of Codecool Phnom Pen (capital of Cambodia) are fed up, that despite the strict house rules, no one cares about collecting the waste in a selective way in the school. They decided to make an automated dustbin, which can detect different types of garbage, and can put them to different containers automatically.
Mentors at Codecool usually have a whole bunch of things to do, and they aren't exceptions either, so they don't have time to implement the dustbin's software. Luckily it's internal computer is capable of running Python scripts...
Have you found out yet??? YES, it's your job to implement it in an Object-Oriented way! :-)
Please find the following files in this directory:
This is the file containing a regular garbage's business logic.
- name: a string, stroring some custom name of the exact garbage object
This is the file containing the business logic of a garbage made of paper. PaperGarbage class inherits the logic of the Garbage class.
- name: a string, stroring the name of the garbage (should be inherited from the Garbage)
- is_squeezed: a Boolean, storing if the garbage is squeezed (True) or not (False)
- when called, it sets the object's is_squeezed attribute to True
This is the file containing the business logic of a garbage made of plastic. PlasticGarbage class inherits the logic of the Garbage class.
- name: a string, stroring the name of the garbage (should be inherited from the Garbage)
- is_clean: a Boolean, storing if the garbage is clean (True) or not (False)
- when called, it sets the object's is_clean attribute to True
This file contains a custom exception, called DustbinContentError, which is raised by the Dustbin in some error cases (see below). It's already implemented, so you don't have to touch this file at all.
This file should contain all the logic, what our automated dustbin can do.
- color: a string, storing the dustbin's color
- paper_content: a list, storing PaperGarbage instances
- plastic_content: a list, storing PlasticGarbage instances
- house_waste_content: a list, storing Garbage instances
- Receives an argument.
- If the argument is an instance of the PlasticGarbage class, and it's clean, then it puts that into the plastic_content list. If the PlasticGarbage instance is not clean, it raises a DustbinContentError exception.
- If the argument is an intance of the PaperGarbage class, and it's squeezed, then it puts that into the paper_content list. If the PaperGarbage instance is not squeezed, it raises a DustbinContentError exception.
- if the argument is an instance of the Garbage class (but not a PaperGarbage or a PlasticGarbage), then it puts that into the house_waste_content list
- if the argument is not an instance of the classes above, it raises a DustbinContentError exception.
- If it's called, plastic_content, paper_content and house_waste_content lists get emptied
This file contains test cases for the specification above. You mustn't touch it, but it worth checking it, as it can help understand the specification above.
You're ready with your assignment when all the tests run with success. You can run them with the usual command python test.py