Sit232 - object oriented development project you are


OBJECT ORIENTED DEVELOPMENT PROJECT-

LEARNING OUTCOMES -

  • Apply object-oriented concepts including abstraction, encapsulation, inheritance, and polymorphism.
  • Solve programming problems using object-oriented techniques and the C# programming language.

PROJECT DESCRIPTION - You are required to develop a console application to manage customers and accounts using C#. Your application will include the following classes.

1. Customer - This class represents customers and has the following information

1.1. Attributes

  • First name: Customer's first name. This information is required1 and the attribute is a readable/writeable attribute.
  • Last name: Customer's last name. This information is required and the attribute is a readable/writeable attribute.
  • Address: Customer's address. This information is required and the attribute is a readable/writeable attribute.
  • Date of birth: Customer's date of birth. This information is required and the attribute is a readable/writeable attribute. You should use DateTime4 for the datatype of this attribute. Customer must be at age of 16 or above. For the sake of simplicity, only the year of birth will be considered. For example, given that the current year is 2018, only customers whose year of birth is 2002 or prior can be maintained in the application. You can get the current year via DateTime.Now.
  • Contact number: Customer's contact number. A contact number must contain exactly 10 digits. However, this attribute is not required and thus can be blank.
  • Email: Customer's email. This attribute is not required and thus can be blank.
  • List of accounts: Customer's accounts. Account class is described in section 2. You could use List5 to maintain the list of accounts. This attribute is a read-only attribute.

1.2. Methods

  • Constructor: This constructor receives input parameters including first name, last name, address, date of birth, contact, and email. Note that if customer does not have a contact number or email address, those fields will be set to blank.
  • Copy constructor: You need to implement a copy constructor. Please revisit Prac 4.1 for an example of copy constructors.
  • Add account: This method adds an account to the list of accounts. This method should receive only an account as input parameter.
  • Sum balance: This method returns the total balance of all accounts owned by the customer.
  • ToString: This method returns a string including first name, last name, address, date of birth, contact, email, and total balance. Total balance is the sum of the balances of all accounts owned by the customer. The total balance is required to be presented in 1 decimal digit, e.g. 2,510.5 (see Figure 1 attached). Please revisit Prac 4.1 for an example of ToString() method.

2. Account - This class represents accounts and has the following information.

2.1. Attributes

  • ID: Account's ID. This attribute is required and is read-only. It cannot be set manually but generated automatically. In particular, the first account (in the system) will have ID = 1, accounts opened after that will have ID = 2, 3, etc. Hint: ID should be declared as static and its datatype should be unsigned int (uint) or unsigned long (ulong).
  • Opened date: Account's opened date. This information is required and is read-only. The opened date of an account must be on or before the current date (obtained using DateTime.Now). Hint: Comparison of DateTime variables can be performed using DateTime.Compare.
  • Closed date: Account's closed date. This attribute does not require a value if the account is still active and is set by the date the account is closed otherwise. This attribute is a read-only attribute. This attribute is set indirectly by calling method "Close" (described in Section 2.2).
  • Active: Account's status. This attribute represents account's status that can be active or inactive. This is a read-only attribute. You could use bool for the datatype of this attribute. This attribute is set indirectly by calling "Close" method (described in Section 2.2).
  • Balance: Account's balance. This attribute requires a value with 0 for default value. Balance must be equal or greater than 0. This is a readable/writable attribute.
  • Owner: Account's owner. Account's owner is a Customer object. This attribute is read-only and is given via constructor's parameters.

2.2. Methods

Constructors: There are two constructors

  • Constructor 1: This constructor receives input including an owner, an opened date, and an initial balance. In this constructor, the opened date and initial balance need to be validated (see description of opened date and balance in section 2.1). When an account is created its "Active" attribute needs to be set to true.
  • Constructor 2: This constructor has less parameters. In particular, it receives input including an owner and an initial balance. In this constructor, the opened date is set by the current date. Note that initial balance also needs to be validated. When an account is created its "Active" attribute needs to be set to true. Constructor 1 should be invoked in Constructor 2. See Prac 4.1 for an example of calling a constructor from another constructor.

Close: This method closes the account. In the method, "Active" is updated and "Closed date" is set to the current date. Note that Close method is only applied to active accounts.

Transfer: This method receives input as an account and amount of money and aims to transfer that amount from the current account to the input account. For example, let a and b be two accounts, a.Transfer(b, 1000) will transfer $1,000 from account a to account b. However, this method acts differently depending on the account types (see more details in Section 3 and 4). Note that Transfer method is only applied to active accounts.

Calculate interest: This method calculates and results in the interest of the account. This method acts differently depending on the account types (see more details in Section 3 and 4).

Update balance: This method is called when the balance needs to be updated. We assume that in the end of each month, the balance is re-calculated and updated based on the interest as follow, new balance = old balance + interest. Thus, this method will need to call Calculate interest to fulfill its task.

ToString: This method returns a string including account's ID, opened date, balance, owner's name, and closed date (if the account has been closed). The balance is required to be presented in 1 decimal digit, e.g. 2,510.5 (see Figure 1 attached)

There are two types of accounts: Type1Account and Type2Account.

3. Type1Account - This is a sub-class of Account and contains the following information.

3.1. Attributes

  • Annual interest rate: The interest rate is fixed to 2.0 for all type 1 accounts and is a read-only attribute. Hint: this attribute should be static.

3.2. Methods

  • Constructors: Like Account class, this class has two constructors with similar parameters.
  • Deposit: This method receives an amount of money as input and adds this amount to the balance. Note that, this operation is only applied to active accounts and the deposit must be greater than 0.
  • Withdraw: This method receives an amount of money as input and deducts this amount from the balance. Like "Deposit" method, the withdrawal is only applied to active accounts and the withdrawn money must be positive and not exceed the balance.
  • Transfer: This method overrides the Transfer method declared in Account class, which transfers a given amount of money to a given account. The transferred amount of money must be greater than zero and cannot exceed the balance of the source account.
  • Calculate interest: This method overrides the Calculate interest method declared in Account class. The interest can be calculated using the formula below, Interest = (Annual interest rate / 365 / 100) * nDays * Balance where nDays is the number of days since the first day of the current month to the current day. If the account is opened after the first day of the current month, then nDays is the number of days since its opened day to the current day. For example, given March 29th, 2018 as the current date and if the account was opened on February 20th, 2018, then nDays = 29 - 1 = 28. If the account was opened on March 10th, 2018, then nDays = 29 - 10 = 19.

Hint: You could use Timespan class and Subtract method (of DateTime) to calculate difference between DateTime variables. For example, let d1 and d2 be two DateTime objects, the difference in months between d1 and d2 can be calculated as, TimeSpan span = d1.Subtract(d2).

4. Type2Account

4.1. Attributes

  • Monthly deposit: This type of account requires its owner to make a deposit monthly. Monthly deposit is the amount money that the owner deposits in the current month. This attribute is a readable/writable attribute. We assume that the owner makes this monthly.
  • Annual interest rate: Like Type1Account, this interest rate is fixed for all type 2 accounts and is a read-only attribute. However, its value is higher and is set to 3.0.
  • Deposit interest rate: This interest rate is fixed for all type 2 accounts. However, it is applied only to the Monthly deposit and is set to 4.0.

4.2. Methods

  • Constructors: Like Account class, this class has two constructors with similar parameters.
  • Transfer: This method overrides the Transfer method declared in Account class, which transfers a given amount of money to a given account. The transferred amount of money must be greater than zero and cannot exceed the balance of the source account. However, unlike Type1Account, a Type2Account can only transfer money to a Type1Account of the same owner. Hint: you could use GetType() and typeof for check the type of an account object. For example, let a be an account, we could check whether a is an instance of Type2Account by using this condition a.GetType() == typeof(Type2Account).
  • Calculate interest: This method overrides the Calculate interest method declared in Account class. The interest can be calculated using the formula below, Interest = (Annual interest rate / 365 / 100) * nDays * Balance + (Deposit interest rate / 365 / 100) * nDays * Monthly deposit where nDays is computed similarly as in the Calculate interest method of Type1Account.
  • Update balance: This method calls the UpdateBalance method in Account class and then set the Monthly deposit to 0.

5. Main method

You are to implement a Main method to test your classes. The Main method must include the following step (you MUST keep the same order),

a. Creating 3 customers (c1, c2, and c3) with the following information

c1:

c2:

c3:

b. Creating 5 accounts (a1, a2, a3, a4, and a5) with the following information

a1 (Type1):

a2 (Type2):

a3 (Type1):

a4 (Type2):

a5 (Type2): . Note that when the opened date is not provided, it will be set to the current date.

c. Deposit -$200 to a1

d. Transfer $6,000 from a2 to a1

e. Transfer $2,000 from a2 to a1

f. Transfer $1,000 from a1 to a2

g. Set the monthly deposit for a2 to $200

h. Deposit $5,000 to a3

i. Withdraw $6,000 from a3

j. Transfer $1,000 from a3 to a1

k. Transfer $500 from a3 to a2

l. Set the monthly deposit for a4 to $1,000

m. Transfer $100 from a4 to a1

n. Set the monthly deposit for a5 to $1,500

o. Transfer $500 from a5 to a4

p. Calculate the interests of a1, a2, a3, a4, and a5 and display them on the console window

q. Update balance of a1, a2, a3, a4, and a5

r. Close a3 and a5

s. Display the information of a1, a2, a3, a4, and a5 by calling ToString() method of these accounts

t. Display the information of c1, c2, and c3 by calling ToString() method of these customers.

Attachment:- Assignment Files.rar

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Sit232 - object oriented development project you are
Reference No:- TGS02744575

Expected delivery within 24 Hours