Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON 2.7 (50 Points) In this assignment you have been given a very simple framework that pits an army of Clones against an army of
PYTHON 2.7
(50 Points) In this assignment you have been given a very simple framework that pits an army of Clones against an army of Robots. It is your job to create Clone and Robot classes that are compatible with the framework. In this lab, you will be working with the attached file clone wars.py The army of Robots will attack first. Each Robot will shoot randomly at Clones (up to 5 times) until it hits one for damage. Once all Robots have attempted to attack, it will be the Clones' turin The army of Clones will attack second. Each Clone will shoot randomly at Robots (up to 5 times) until it hits one for damage. After a Clone hits a Robot, there is a 0.3% chance it will issue Order 66, This will cause all Clones to shoot themselves instead of their randomly chosen targets when they pull the trigger on their blasters. Once all Clones have attempted to attack, it will again be the Robots' turn Once either all Clones are dead or all Robots are dead, the simulation will end Robot is the simpler of the two classes you must implement, so we will discuss it first: Robots should have the following private attributes - hitpoints - the "life" of the robot solder. When this reaches zero, the robot dies -damage _ the damage dealt by the robot when it shoots and enemy - dead - boolean that tracks if the robot is dead Robots should have the following public methods takeDamage - This method should accept an integer representing an amount of damage inflicted upon the Robot. This amount of damage should be subtracted from the Robot's hitpoints. If this results in the Robots hitpoints being non-positive, then the Robot's dead attribute should be set. shoot - This method should accept a target, which could be either a Robot or Clone object. If the Robot is not dead, the target should take damage. (In other words, dead robots can't shoot) dead - This is a simple accessor method for returning the value of the Robot's private dead attribute - hitpoints - This method accepts no parameters and returns a string. If the Robot is not dead, the string should contain the Robot's current hitpoints formatted to 4 digits. If the Robot is dead, the returned string should simply contain DEAD (50 Points) In this assignment you have been given a very simple framework that pits an army of Clones against an army of Robots. It is your job to create Clone and Robot classes that are compatible with the framework. In this lab, you will be working with the attached file clone wars.py The army of Robots will attack first. Each Robot will shoot randomly at Clones (up to 5 times) until it hits one for damage. Once all Robots have attempted to attack, it will be the Clones' turin The army of Clones will attack second. Each Clone will shoot randomly at Robots (up to 5 times) until it hits one for damage. After a Clone hits a Robot, there is a 0.3% chance it will issue Order 66, This will cause all Clones to shoot themselves instead of their randomly chosen targets when they pull the trigger on their blasters. Once all Clones have attempted to attack, it will again be the Robots' turn Once either all Clones are dead or all Robots are dead, the simulation will end Robot is the simpler of the two classes you must implement, so we will discuss it first: Robots should have the following private attributes - hitpoints - the "life" of the robot solder. When this reaches zero, the robot dies -damage _ the damage dealt by the robot when it shoots and enemy - dead - boolean that tracks if the robot is dead Robots should have the following public methods takeDamage - This method should accept an integer representing an amount of damage inflicted upon the Robot. This amount of damage should be subtracted from the Robot's hitpoints. If this results in the Robots hitpoints being non-positive, then the Robot's dead attribute should be set. shoot - This method should accept a target, which could be either a Robot or Clone object. If the Robot is not dead, the target should take damage. (In other words, dead robots can't shoot) dead - This is a simple accessor method for returning the value of the Robot's private dead attribute - hitpoints - This method accepts no parameters and returns a string. If the Robot is not dead, the string should contain the Robot's current hitpoints formatted to 4 digits. If the Robot is dead, the returned string should simply contain DEADStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started