Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Update the Town Class In the initializer for the Town class, ensure that the value of the name attribute is stored with the first letter

Update the Town Class
In the initializer for the Town class, ensure that the value of the name attribute is stored with the first letter as a capital letter and every other letter in lower case, no matter what value is passed to the function.
Example: if the value of the name argument is bloomington, the initializer should store Bloomington in the self.name attribute
Create a Unit Test file for MonsterTown
Create a new file named test_monstertown.py at the root of your project.
Import the unittest package, your MonsterTown module, and structure the file as demonstrated in the materials for this week. You will create at least one class that will inherit from the unittest.TestCase class. (See the provided starter code for details.)
Add a Unit Test for the Town Class
In the unit test file, use the setUp() method to create 3 instances of class Town with various attributes.
Create a method named testTownInitializer() that validates the format of the Town class name attribute (check to see that a Town with the name of bloomington is stored as Bloomington).
Test all three of the Town objects you created in the setUp() method.
Run your unit test file and make modifications to your Town class until your program passes all tests.
Update the Monster Classes
Update all 3 Monster classes (Monster, Mutant, and Vampire) to add a property named mmi (MMI stands for Monster Mass Index.) This property will return a float.
In the Monster class:
The implementation of the mmi property can simply be pass (no logic is needed in the property)
In the Mutant class:
The mmi is calculated as (weight /200)/(height *.10)
In the Vampire class:
The mmi is calculated as (weight/height)*.45
Add Unit Tests for Monster Classes
1. In the unit test file setUp() method, add the code to create two Mutant objects and two Vampire objects.
2. Create a method named testMutantTerrorizeTown() that uses the Town and Mutant objects created in the setUp() method. Write tests that validate that the values for population, buildings, and stoplights will never go below zero no matter how many times the town is terrorized.
Hint: You can modify the Town or Mutant objects however you need to within this method. For example, you could set the towns population to just 5 and terrorize the town 5 times to see how your code behaves.
3. Create a method named testVampireTerrorizeTown() that uses the Town and Vampire objects created in the setUp() method. Write tests that validate that the values for population will never go below zero no matter how many times the town is
terrorized. Also write tests to ensure that the values for buildings and stoplights never change after terrorizing.
4. Create a method named testMutantMMI() and write tests that validate the calculated value of a Mutants mmi property.
a. A Mutant with a height of 10 and weight of 6000 should have an mmi of 30.
b. A Mutant with a height of 2 and weight of 200 should have an mmi of 5.
5. Create a method named testVampireMMI() and write tests that validate the calculated value of a Vampires mmi property.
a. A Vampire with a height of 3 and weight of 170 should have an mmi of 25.5.
b. A Vampire with a height of 1.5 and weight of 90 should have an mmi of 27.

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_2

Step: 3

blur-text-image_3

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions