Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package package1;
- import java.util.*;
- import java.io.*;
- public class Account extends CheckAccount {
- ArrayList<Transactions> List2= new ArrayList<Transactions>();
- //Variables
- //protected String date;
- protected String name;
- protected int Account_num;
- protected double AnuualInterestRate;
- double Balance;
- // constructors
- public Account () {}
- public Account (String Date, String name, int Account_num, int Balance ,Double AnuualInterestRate) {
- this.name=name;
- this.AnuualInterestRate=AnuualInterestRate;
- this.Balance=Balance;
- this.Account_num=Account_num;
- }
- // getters and setters
- /*public String getDate() {
- return date;
- }
- public void setDate() {
- Scanner in = new Scanner(System.in);
- System.out.println("Enter the Date ");
- date = in.nextLine();
- }
- */
- public String getName() {
- return name;
- }
- public void setName() {
- Scanner in = new Scanner(System.in);
- System.out.println("Enter the Name ");
- name = in.nextLine();
- }
- public int getAccount_num() {
- return Account_num;
- }
- public void setAccount_num() {
- Scanner in = new Scanner(System.in);
- System.out.println("Enter the Account Number ");
- Account_num = in.nextInt();
- }
- public double getAnuualInterestRate() {
- return AnuualInterestRate;
- }
- public void setAnuualInterestRate() {
- this.AnuualInterestRate = AnuualInterestRate;
- /* Scanner in = new Scanner(System.in);
- System.out.println("Enter the AnuualInterestRate ");
- AnuualInterestRate = in.nextDouble();*/
- }
- //input file
- /*void Balance () throws IOException {
- File f= new File ("Balance.txt");
- FileInputStream fis = new FileInputStream(f);
- byte [] b = new byte [(int)f.length()];
- Balance = fis.read(b);
- }*/
- public double getBalance() {
- /*FileOutputStream fos = new FileOutputStream("Balance.txt");
- fos.write("Balance.txt".getBytes());
- fos.flush();*/
- /*String s =new String (b);
- System.out.println(s);
- fis.close();*/
- return Balance;
- }
- public void setBalance() throws FileNotFoundException {
- Scanner in = new Scanner(new File ("Balance.txt"));
- // System.out.println("Enter the Balance ");
- Balance = in.nextDouble();
- //this.Balance = Balance ;
- /*String s =new String (b);
- System.out.println(s);
- fis.close();
- /*Scanner in = new Scanner(System.in);
- System.out.println("Enter the Balance ");
- Balance = in.nextDouble();*/
- //FileInputStream fis = new FileInputStream("Yasmeen.txt");
- }
- //Transactions Methods
- //1)withdraw
- public double Withdrawal(double amount) {
- if(Balance< amount) {
- System.out.println("Invalid Amount");
- }
- else if (amount > 8000) {
- System.out.println("Invalid");
- }
- else {
- Transactions t = new Transactions(new Date (), amount,'W');
- List2.add(t);
- Balance -=amount;
- }
- return Balance;
- }
- //2)deposit
- public double Deposit(double amount) {
- Transactions t = new Transactions(new Date (), amount,'D');
- List2.add(t);
- Balance += amount;
- return Balance;
- }
- //3)AnnualInterestRate
- public double AnuualInterestRate() {
- /* Transactions t = new Transactions(new Date (),'R');
- List2.add(t);*/
- Balance +=(Balance *0.015);
- return Balance ;
- }
- //Display Methods
- //1) Transactions
- /*void DisplayTransactions() throws IOException {
- for(int i=0 ; i<List2.size() ; i++) {
- FileWriter myWriter = new FileWriter("outcome.txt");
- myWriter.write(List2.get(i).date +" "+List2.get(i).transaction +" " + List2.get(i).amount +" " +Balance );
- }
- }*/
- public void DisplayAccountInformation() {
- try {
- FileWriter myWriter = new FileWriter("outcome.txt");
- myWriter.write("Account Number : "+Account_num +'\n');
- myWriter.write("Current Balance : "+Balance );
- myWriter.write("\n");
- myWriter.write("------------------After Transaction------------------");
- myWriter.write(" Date Type Amount New Balance");
- for(int i=0 ; i<List2.size() ; i++) {
- }
- myWriter.close();
- } catch (IOException e) {
- System.out.println("An error occurred.");
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement