From e5a1bfa3d3b9cf746785b0140ba42f38f64a72c7 Mon Sep 17 00:00:00 2001 From: AbitBrookish Date: Tue, 9 May 2023 21:56:25 -0400 Subject: [PATCH] create classes, variables, methods and tests --- .idea/dbnavigator.xml | 12 ++-- .idea/misc.xml | 2 +- .../com/example/bankaccount/BankAccount.class | Bin 0 -> 2362 bytes .../com/example/main/Main.class | Bin 0 -> 1182 bytes src/com/example/bankaccount/BankAccount.java | 59 ++++++++++++++++-- src/com/example/main/Main.java | 19 +++++- 6 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 out/production/JavaIntro2Debrief/com/example/bankaccount/BankAccount.class create mode 100644 out/production/JavaIntro2Debrief/com/example/main/Main.class diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml index 7f0b6a1..0ded4ec 100644 --- a/.idea/dbnavigator.xml +++ b/.idea/dbnavigator.xml @@ -2,7 +2,7 @@ - + @@ -27,6 +27,9 @@ + + + @@ -99,6 +102,7 @@ + @@ -145,11 +149,11 @@ - - + + - + diff --git a/.idea/misc.xml b/.idea/misc.xml index d15472f..07115cd 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/out/production/JavaIntro2Debrief/com/example/bankaccount/BankAccount.class b/out/production/JavaIntro2Debrief/com/example/bankaccount/BankAccount.class new file mode 100644 index 0000000000000000000000000000000000000000..0698ac76273cb2819bbfed5e50f838c842ab2ead GIT binary patch literal 2362 zcma)7ZBrXn6n-uVY)BJG(?APajJA~|eTmh!T0&nah)tz{LTO8VyKJtoO|l!anklW8 z#u2&+^^2|ghH46kvfdp@U=&9Mj15WHrlNi>hB1Mdxuwi1oyYMKUN&$%feE~_FU24@ zRqBhDthwb)+i9v<>C(wat{Y^2ec;-kEE|7=IDwM}P9^XR`^cYaddMSpyz~T9pU2(J9mbX=D%58fp8^>v!F>p44b0`WN@vF4olzBF^qniCM z5ZBT~cRqnP@s_~Rx~!^M$2O&RmtiQmp0qtz+s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ance) { + System.out.println("Funds withdrawn: "); + return false; + } else { + balance -= (withdrawalAmount + transactionFee); + System.out.println("Funds withdrawn: " + withdrawalAmount); + return true; + } + } /* Here you should write your deposit method @@ -62,14 +99,28 @@ Class methods(return types): 2. return true if successful otherwise, return false */ - + public boolean deposit(double depositAmount){ + if(depositAmount < 0){ + System.out.println("Funds not deposited."); + return false; + } else { + balance += depositAmount; + System.out.println("Funds deposited: " + depositAmount); + return true; + } + } /* Here you should write you toString method requirements: 1. returns a String that represents all your instance field values */ - + public String toString(){ + return "account name: " + nameOnAccount + + "\naccount number: " + accountNumber + + "\naccount type: " + accountType + + "\nbalance: " + balance; + } } diff --git a/src/com/example/main/Main.java b/src/com/example/main/Main.java index 10c7f11..aed2974 100644 --- a/src/com/example/main/Main.java +++ b/src/com/example/main/Main.java @@ -1,8 +1,6 @@ package com.example.main; - // import statement for our BankAccount class import com.example.bankaccount.BankAccount; - public class Main { /* Your main method here should create two instances of BankAccount @@ -16,7 +14,24 @@ we do this to ensure that our class handles input as expected this means that it also has to handle invalid input appropriately */ public static void main(String[] args) { + BankAccount savings = new BankAccount("Alan", "savings", 56858494, 10000.00); + BankAccount checking = new BankAccount("Jamilla", "checking", 9874733, 2.30); + +// tests + System.out.println(savings.getName()); + System.out.println(savings.getAccountType()); + System.out.println(savings.withdraw(5000)); + System.out.println(savings.deposit(50.55)); + System.out.println("\n"); + System.out.println(savings.toString()); + System.out.println("\n"); + System.out.println(checking.getName()); + System.out.println(checking.getAccountType()); + System.out.println(checking.withdraw(5.50)); + System.out.println(checking.deposit(75)); + System.out.println("\n"); + System.out.println(checking.toString()); } }