Question
C Sharp Visual Studio Create an ordinance class This class will be extended by torpedo, ion bomb, and laser. The ordinance class will have Virtual
C Sharp Visual Studio
Create an ordinance class
This class will be extended by torpedo, ion bomb, and laser.
The ordinance class will have
Virtual int damage field
Public read-only property for the damage
The torpedo class have
A damage field
Will set the damage field to 5
The ionBomb class
A damage field
Will set the damage field to 10
The laser class
A damage field
Will set the damage field to 1
Create a class name starship
The starship class will be extended by a cruiser class and destroyer class.
The starship class will have
Private field of ship name and a get property for this field
Private field of shield level (the maximum health of the shield will be 100) and a get and set property for this field
Private int fields health and of max health and a get property for this field
Private field of string for condition (it will end up holding the values of destroyed hulk, pristine, or damaged) Create a read only property for this as well
Properties to set and get are properties, not get or set functions
Private field named weapon of type ordinance (no properties for this)
Private int field of weaponCount
Constructor that will
take in a string of the ship name, max ship health
will set the properties according to the values sent in
will set the condition to pristine
will set the shields to 100
set the health to the max health
Method Load
Takes in an ordinance type object
Increases the weaponCount value by 2
Sets the weapon field to the type that was sent in
Method of FireParameters of:
starship object (the target)
returns a boolean
if the ship has the ordinance type left (weaponcount > 0) it will
reduce the count by one
call the targets takehit function
will use the weapons damage value (the ship has only one weapon) to send to the takehit function
if there are no weapons left, output a message that you are out of ordinance
a destroyed hulk cannot fire
returns true if it fired (eg. Had the ordinance)
returns false if it did not fire
Method of TakeHit
Will take in an integer of the damage done
This will reduce the shield health by the damage parameter
If the shield gets to zero the remaining damage will be applied the ships health
The damage will change the status of the ship
destroyed hulk if health = 0
damaged if health <> max health
pristine if health = max health
will print out that it was attacked and display its health, max health and ship condition
If destroyed, print out the name of the ship and that it was destroyed
The cruiser has
A constructor that will take in a name
It will send to the parent classs constructor Cruiser -
The destroyer has
A constructor that will take in a name
It will send to the parent classs constructor Destroyer -
Have ALL classes outside the main program. (DO NOT embed classes)
In the main
create a bunch of different types of ships and assign names to them
create the different ordinances ( etc. ionBomb ib = new ionBomb();)
have each ship load a different ordinance
Have the ships fire at each other
Step 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