Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help!! python need the of the class hero assignment use the bold code as a guide thankyou.. # Alien Blaster # Demonstrates object interaction

please help!! python need the of the class hero assignment use the bold code as a guide thankyou..

# Alien Blaster

# Demonstrates object interaction

class Player(object):

""" A player in a shooter game. """

def blast(self, enemy):

print("The player blasts an enemy. ")

enemy.die()

class Alien(object):

""" An alien in a shooter game. """

def die(self):

print("The alien gasps and says, 'Oh, this is it. This is the big one. " \

"Yes, it's getting dark now. Tell my 1.6 million larvae that I loved them... " \

"Good-bye, cruel universe.'")

def main():

print("\t\tDeath of an Alien ")

hero = Player()

invader = Alien()

hero.blast(invader)

# main

main()

input(" Press the enter key to exit.")

use this code as guide

Class Hero

Attributes

name, set so it defaults to Arnold, but can be reset to some other name.

health, initialized to 10

shield, initialized to 10, but is not used in this game.

life, initialized to 1

Methods:

Constructor, init (), takes a string parameter that defaults to Arnold.

blast(), takes an player object argument to communicate that the enemy has been hit. Blast() implements an immediate call to the enemy die() method.

die(), no arguments, decrements health. Decrements lives, when health gets to 0. When lives is 0, the soldier dies.

Class Alien

Same as Hero

Main()

Game over when one combatant is dead.

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

Step: 3

blur-text-image

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago