Home > Net >  Which bosses know how to do this in c #
Which bosses know how to do this in c #

Time:12-18


Write a console application, create the following categories: shooter, pea shooter, ice shooter, zombie

As a striker Shooter (abstract class)

By name, Numbers for parameters define a constructor

Members:

_name name (the name of the striker, such as: 1 scorer, no. 2 scorer)

Number _code

HP _blood=1000;

Encapsulated with properties of above three protected members, including _name, _code read-only, _blood read-write



Methods

Restore blood AddBlood (int ")

Striker HP increased 1

2 return a string "striker XXXX (_name), no. XXXX (_code) plus blood, blood XXXX ("

), the total number of existing health XXXX "

Abstract methods

Playing zombie Fire



Class: pea Shooter PeaShooter inherited from striker Shooter

Overloaded methods play zombie Fire

Returns a string "pea striker playing zombie,,,, no. XXXX (_code) XXXX (_name) of the pea striker to play a zombie, blood volume increase 100, total number of existing health XXXX"

If HP less than or equal to 0, it returns the string "pea striker playing zombie,,,, no. XXXX (_code) XXXX (_name) of the pea shooter blood flow has been dry, unable to attack, please add blood"



Class: ice striker IceShooter inherited from striker Shooter

Overloaded methods play zombie Fire

Returns a string "ice striker playing zombie,,,, number of XXXX (_code) XXXX (_name) ice striker to play a zombie, blood volume increase 200, total number of existing health XXXX"

If HP less than or equal to 0, it returns the string "ice striker playing zombie,,,, number of XXXX (_code) XXXX (_name) blood flow has been dry ice striker, unable to attack, please add blood"



Class: Zombie Zombie class (static)

Methods: eat striker EatShooter (Shooter Shooter);

Each call to this method will lead to HP 500 striker, and returns a string "zombies eat striker,,,, number of XXXX (_code) XXXX (_name) striker was eaten by a zombie, HP reduced by 500, total number of existing health XXXX"



According to above requirements writing class, can according to need to add members, defining methods of parameters, etc.), in the main program, respectively, to create a number of pea shooter, ice striker instance, statistics to create a pea shooter, ice striker (in their respective constructors by static member statistics) number, and in the console output, AddBlood call each instance methods, the Fire and the method of static class Zombie EatShooter, simulation of various scenarios, the console output the results of various methods,





CodePudding user response:

Don't just say, chat under budget

CodePudding user response:

20 w joy beans, one less all not for you, to do private chat
  •  Tags:  
  • C#
  • Related