Java TOPIC 09 – INTRODUCING OBJECTS LESSON WORK
QUESTION 1 (GROUP WORK) QUESTION 1A
Create a BadGuy class with datafields
for
QUESTION 1B Create a BadGuyTester class that will create two different BadGuy objects.
Make sure you fill in their datafield
values. QUESTION 1C Continuing in
the same class as 1B, make each BadGuy attack the
other and update their datafields accordingly (hp will be reduced by the other's damage). Then output
the state of each BadGuy with a line similar to: Godzilla now has 932 of 950 hp. QUESTION 2 Then, in
another class called StudentTester, inside the main
function, create the student object that represents you. Simply set each datafield
to correspond to you. Then output the
values to screen.
Create a BankAccount object and write the required statements to
update the account so that it matches the actions below. Output the balance of the account after
each action. ACTIONS 1-You open an
account with 500 dollars in it. The
account has a 5 dollars per month charge to run the account and you pay 2
dollars for each withdrawal at an ATM. 2-You deposit
200.0 into the account. 3-It is the
end of the month. 4-You deposit
150.0 into the account. 5-You
withdraw 300 from the account. 6-You
withdraw 100 at an ATM from the account. 7-It is the
end of the month. 8-Output the
value of the account’s balance to the screen.
Compare your answer with your neighbour if
possible. |
|
|