Builders

 

It is the year 2042 and, with Earth's human population dwindling, mice have been trained as builders to rebuild major cities after the big war. Each Builder has

  • a name, passed as a parameter when initialised
  • a box of three tools from the following list, initialised as a 3-element array of None.
    1. a hammer
    2. a paintbrush
    3. a screwdriver
    4. a glue gun
    5. a tape measure
    6. a pair of pliers
    7. a power drill
  • an hourly pay-rate eg $20 per hour, passed as a parameter when initialised.
  • total money earned, initialised to 0

Task 1 - Class design

You will design the Builder class

Design a constructor method that will populate class variables with the data above when a Builder object is constructed. Note: the class variable that stores the three tools is a three-element array of None. Also, the hourly rate ranges from $15 per hour to $30 per hour. The constructor method should ask for a valid value if the parameter is outside this range.

Design accessor methods for each class variable.

Design mutator methods for each class variable.

Design a method called addTools which will ask a user to type 3 tools and add them to the array class variable. The method should check that the tool names being input are valid.

Save your solution as builder-1.py

Task 2 - A computer program

Design a computer program that will construct two Builder objects fully populated with data. ie after construction the addTools method is called for both builders.

The program will compare the two builders' toolsets and display any items that are in both tool sets. A message similar to this will be displayed: Both builders have a wrench and a screwdriver.

Save your solution as builder-2.py

Task 3 - Adaptive maintenance

Redesign the addTools method. Instead of a user entering 3 tools into the toolset, the method will randomly pick 3 tools from the available options. No tool can be selected more than once.

Save your solution as builder-3.py

Task 4 - Adaptive maintenance

Write a computer program that will construct a team of builders.

The program then allows the user to input the name of a tool and the program will list the names of all builders who have that tool, or a message No builder has that tool.

This process should be in a loop so that the user can keep entering the name of a tool instead of having to keep running the program.

Save your solution as builder-4.py

Testing

Make sure you are thoughtful when testing your solution.

If your code has a validation check, test your code with acceptable/valid data and unacceptable/invalid data.