CPT121 Task 6.1.3 Practice Exercises Solved

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

Task 6.1.3 Practice Exercises

Inheritance and subclass basics

  1. In the following pair of classes identify the superclass and subclass: a) Employee / Manager
    1. Polygon / Triangle
    2. Vehicle / Car
    3. GeometricObject / Rectangle
    4. Integer / Number
    5. Object/Person
  2. If class C extends class B and class B extends class A then which of the following statement is true?
    1. an instance of C can use all public methods of classes A, B and C
    2. an instance of A can use all public methods of classes A, B and C
  3. Extend the Account class to create a new subclass called ChequeAccount for modelling a cheque account which incorporates the following functionality:
    • Cheque accounts can use an overdraft facility, so the new class will need instance variables for the overdraft limit and the amount overdrawn.
  • The overdraft should not be used unless the current balance is insufficient to cover a

withdraw.

  • Cheque account holders may be charged for withdrawals or transfers, so the new class will also need a new instance variable for the number of transactions that have been made.
  • A new constructor will be required that accepts the account id, name, initial balance and overdraft limit. This constructor should use the super() facility to initialize the account id, name and balance.
  • This constructor should set the amount overdrawn to 0 and the transaction count to 0.
  • Define another (overloaded) constructor which only accepts the account name, id and balance for the new ChequeAccount (for customers who do not wish to use the overdraft facility yet)
  • This constructor should set the overdraft limit to 0, amount overdrawn to 0 and transaction count to 0
  • Decide whether accessors and/or mutators will be required for the three new instance variables.
  1. Write a program which creates two CAccount objects and trace where the details supplied for each object will be stored upon construction. Describe how the various values supplied when creating the find their way into the corresponding superclass and subclass-level instance variables?

 

  • task_6_1_3-ij7ayr.zip