Repository navigation
Expand file tree
/
Copy pathAccountManager.java
More file actions
70 lines (58 loc) · 1.93 KB
/
Copy pathAccountManager.java
File metadata and controls
70 lines (58 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.util.Scanner;
import java.util.Date;
/**
* Write a description of class AccountManager here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class AccountManager
{
// the account
private Account account;
// reader for reading user input
private Scanner reader;
/**
* Constructor for objects of class AccountManager
*/
public AccountManager(Account account)
{
this.account = account;
reader = new Scanner(System.in);
}
public void start()
{
System.out.println("WELCOME TO THE ACCOUNT MANAGER APPLICATION");
boolean finished = false;
for(int i=0; i<3; i++)
{
// get amount
System.out.print("Transaction amount to add?\n>");
String inputAmount = reader.nextLine();
double amount = Double.parseDouble(inputAmount);
// get type
System.out.print("Transaction type?\n>");
String type = reader.nextLine();
// get reference
System.out.println("Transaction reference?");
String reference = reader.nextLine();
// date is today's date
Date date = new Date();
// create transaction and add to account
Transaction transact5 = new Transaction(amount, type, reference, date);
account.addTransaction(transact5);
System.out.println("Transaction added");
account.displayTransactions();
// display balance
System.out.println("Balance:" + account.getBalance());
}
}
public static void main(String[] args)
{
Customer cust = new Customer("Fernando", "Alonso");
Account account = new Account(cust, "12345");
//create AccountManager object and call start method
AccountManager manage = new AccountManager(account);
manage.start();
}
}