Search for question
Question

• What is a good name for a class that represents a Go Card account?

o Be descriptive of what the class represents. Don't include the word "class" in the name.

What services should be provided?

o A constructor (__init___) is required to set up the account with an initial balance.

o It needs to record the amount each ride costs. A method that accepts the amount as a parameter

is required.

o It needs to record the amount for each top-up. A method that accepts the amount as a parameter

is required.

o It needs to be able to report the current balance at any time. A method that returns this is

required.

o A method is required print out a statement of all of the transactions.

We can see from the output of the proposed program that the class needs to store the details of every

transaction in order.

• What data is required to be stored in the object to enable those services?

o So that a method can return the current balance at any time, it would be useful have a field for

the current balance.

o So that the full statement can be printed, the object must store the amount of each transaction,

in order. What data type can grow and keep multiple values in the order they are added?

Problem: Implement the program described above, leaving out the printing of a full statement at the end.

Problem: Implement the program described above, including the printing of a full statement at the end.