Start a new project in your IDE - TheTankProject
This project will have 3 .java files:
A Tank has lots and lots of Missiles. It stores the Missiles in an array.
Each Missile has a Damage Factor - the higher the Damage Factor, the more destructive the missile.
Let's create an in the form of a class for Tanks.
Copy and paste this code into your Tank.java file.
And here is an abstraction of the current design of the Missile class:
Copy and paste this code into your Missile.java file.
A Tank HAS-A array of Missile objects. This is an example of aggregation/containment.
Note: Task 4 and 5 are aimed at students who are motivated a 4 or 5 in AP Computer Science A or a 6 or 7 in IBDP Computer Science.
The City class has a number of buildings eg 40.
When a City object is constructed (instantiated), it stores this number in a class property (attribute).
It also has a method hit which processes Missile objects. It analyses the damage factor of the Missile and reduces the number of buildings by the damage factor of the Missile.
Design the City class using data hiding and any appropriate accessor and mutator methods.
Use the City, Missile and Tank classes to design a game or scenario involving Cities, Tanks and Missiles!
Can you find a way to use the Tank class's getAverageRating method, for example?
object
property
method
create an object/instance of a class
instantiate an object
encapsulate
access
mutate
abstraction
idesyntax file class instantiate constructor type property/attributemethod/behaviour indexabstraction