Starting from:

$30

CPT121-Task 3.2.3 Implementing Program Logic Solved

1.     Redefine the transfer method() of the Account class so that it re-uses the deposit() and withdraw() methods to subtract funds from the source account and add funds to the recipient account.

 

2.     Suppose we are required to provide an operation that allows us to add interest (given the current interest rate) to all account holders.

a)     What will the signature of the method look like?

b)     Give a possible implementation for that method.

3.     Implement a method to print the details of an Account object to the screen in the following format:

                          ID:       A123

Name: Bob the Builder  Balance: $1243.87

...

(all other details should be displayed)

How would you use this method to display the details for an account object from the main program?

4.     Discuss the design for a class to model a simple Person object in your Programming Squad.

You will need to consider the following details in your discussion:

a)     What information is common to all types of people?

b)     How would you create a new person object in another part of the program?

c)     What information might we need to retrieve from a Person object?

d)     What information might we need to change in a Person object?

 

5.     Consider how might you might update the Person class you have designed so that there is a connection between a Person and the parents of that Person (which are also Person objects), allowing for the names of a Person’s parents to be displayed with the Person’s details.

Discuss how the connection between a given Person and the two Person objects which represent the parents of the Person in question could be set up in the main program.

More products