A Go Card account maintains a balance that may be spent on public transport. Users may...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A Go Card account maintains a balance that may be spent on public transport. Users may request a statement that shows all transactions. The only transactions are to top up the account with some positive number of dollars, and to take a ride costing some dollars and cents. The goal for this exercise is to develop a class for a Go Card Account. The class will be tested by a program that simulates transactions, like this: Creating account. Input initial balance: 100 ? ? ? b 3.50 10.90 Balance $85.60 ? t 20 ? x gghhg Bad command. ? t Bad command. ? 9 Statement: event amount ($) balance ($) Initial balance 100.00 Ride 3.50 96.50 Ride 10.90 85.60 Top up 20.00 105.60 Final balance 105.60 Where: ⚫r number simulates a ride costing number dollars; t number simulates a top up of number dollars; b requests the currrent balance; and qends input and prints a statement. Bad inputs are to be reported and ignored. Let us consider the design for a class that represents a Go Card account. To design a class, we consider what services the object(s) must provide (its methods), and what data needs to be stored in the object(s) to support those services. Questions: What is a good name for a class that represents a Go Card account? - Be descriptive of the what the class represents. Don't include the word "class" in the name. ⚫ What services should be provided? - A constructor (__init__) is required to set up the account with an initial balance. -It needs to record the amount each ride costs. A method that accepts the amount as a parameter is required. - It needs to record the amount for each top-up. A method that accepts the amount as a parameter is required. -It needs to be able to report the current balance at any time. A method that returns this is required. -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? - So that a method can return the current balance at any time, it would be useful have a field for the current balance. -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? 4.2 Problem 1 (3 marks) Problem: Implement the program descibed above, leaving out the printing of a full statement at the end. 4.3 Problem 2 (2 marks) Problem: Implement the program descibed above, including the printing of a full statement at the end. A Go Card account maintains a balance that may be spent on public transport. Users may request a statement that shows all transactions. The only transactions are to top up the account with some positive number of dollars, and to take a ride costing some dollars and cents. The goal for this exercise is to develop a class for a Go Card Account. The class will be tested by a program that simulates transactions, like this: Creating account. Input initial balance: 100 ? ? ? b 3.50 10.90 Balance $85.60 ? t 20 ? x gghhg Bad command. ? t Bad command. ? 9 Statement: event amount ($) balance ($) Initial balance 100.00 Ride 3.50 96.50 Ride 10.90 85.60 Top up 20.00 105.60 Final balance 105.60 Where: ⚫r number simulates a ride costing number dollars; t number simulates a top up of number dollars; b requests the currrent balance; and qends input and prints a statement. Bad inputs are to be reported and ignored. Let us consider the design for a class that represents a Go Card account. To design a class, we consider what services the object(s) must provide (its methods), and what data needs to be stored in the object(s) to support those services. Questions: What is a good name for a class that represents a Go Card account? - Be descriptive of the what the class represents. Don't include the word "class" in the name. ⚫ What services should be provided? - A constructor (__init__) is required to set up the account with an initial balance. -It needs to record the amount each ride costs. A method that accepts the amount as a parameter is required. - It needs to record the amount for each top-up. A method that accepts the amount as a parameter is required. -It needs to be able to report the current balance at any time. A method that returns this is required. -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? - So that a method can return the current balance at any time, it would be useful have a field for the current balance. -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? 4.2 Problem 1 (3 marks) Problem: Implement the program descibed above, leaving out the printing of a full statement at the end. 4.3 Problem 2 (2 marks) Problem: Implement the program descibed above, including the printing of a full statement at the end.
Expert Answer:
Answer rating: 100% (QA)
For Problem 1 lets start by designing a class named GoCardAccount that represents a Go Card account ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
The following accounts are used by Mouse Potato, Inc., a computer game maker. Required: For each of the following independent situations, give the journal entry by entering the appropriate code(s)...
-
A psychologist studying addiction tests whether cravings for cocaine and relapse are independent or related. The following table lists the observed frequencies in the small sample of people who use...
-
Consider the following three bonds: Bond 1 Bond 2 Bond 3 (a) Calculate and interpret the present values of each bond. (b) Calculate the Macaulay duration and Modified duration for each bond....
-
If the limit load factor is exceeded, the aircraft will experience structural failure. (True/False)
-
The mobile in Fig. 9-71 is in equilibrium. Object B has mass of 0.885 kg. Determine the masses of object A, C, and D. (Neglect the weights of the crossbars) 7.50 cm 30.00 cm 15.00 cm 5.00 cm 17.50 cm...
-
In your answers, you should make references to support your answers by informal pinpoint citation to book and page number within parentheses. For example: Computer Crime Law at p. __. You do not need...
-
The column is constructed from high-strength concrete and eight A992 steel reinforcing rods. If the column is subjected to an axial force of 200 kip, determine the required diameter of each rod so...
-
The project manager is facing a rush project and the PMO office has authorized the project team to work 7.0 days per week (work week for this project). The PM would like to provide the PMO office...
-
Suppose foo is a reference to an instance of a class Foo. Which of the following is not possible about the variable reference foo.bar? A. bar is an instance variable. B. bar is a static variable. C....
-
What is the output of the following? A. 333 B. 333 806 1601 C. The code compiles but outputs something else. D. The code does not compile. var teams = = new StringBuilder ("333"); teams.append("...
-
Which of the following is not a true statement? A. The first line of every constructor is a call to the parent constructor via the super() command. B. A class is not required to have a constructor...
-
Fill in the blanks: ___________________ is used to call a constructor in the parent class, while ___________________ is used to reference a member of the parent class. A. super and this() B. super...
-
What is the output of the following application? A. 8 B. Line p1 contains a compiler error. C. Line p2 contains a compiler error. D. Another line of code contains a compiler error. E. None of the...
-
BC Back-Country Airlines, Inc., operates leased amphibious aircraft and docking facilities, equipping the firm to transport campers and hunters from British Columbia, Canada, to outpost camps owned...
-
The area of a rectangle is 30 cm 2 and its perimeter is 26 cm. Find the length and width of the rectangle.
-
Jan has two jobs during 2012. One employer withheld and paid FICA taxes on $66,600 of Jan's salary, and the other employer withheld and paid FICA taxes on $44,400 in salary paid to Jan. Calculate the...
-
During 2012, Palo Fiero purchases the following property for use in his manufacturing business: Palo uses the accelerated depreciation method under MACRS, if available, and does not make the election...
-
Mike sells his home to Jane on April 2, 2012. Jane pays the property taxes covering the full calendar year in October, which amount to $2,500. How much may Mike and Jane each deduct for property...
-
Which of the three types of government policiesantitrust, social regulation, and economic regulationis the basis for each of the following? a. Beautician education standards b. Certified Public...
-
Some airline executives have called for reregulation. Why might an executive of an airline prefer to operate in a regulated environment?
-
Suppose the Herfindahl index for domestic production of televisions is 5,000. Does this imply a very competitive or a noncompetitive environment?
Study smarter with the SolutionInn App