diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..2bb13ae
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+BankAccount.java
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..b589d56
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/JavaIntro2Debrief.iml b/JavaIntro2Debrief.iml
index c90834f..17d1596 100644
--- a/JavaIntro2Debrief.iml
+++ b/JavaIntro2Debrief.iml
@@ -1,6 +1,6 @@
-
+
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 0000000..54f5d85
Binary files /dev/null and b/out/production/JavaIntro2Debrief/com/example/bankaccount/BankAccount.class differ
diff --git a/out/production/JavaIntro2Debrief/com/example/main/Main.class b/out/production/JavaIntro2Debrief/com/example/main/Main.class
new file mode 100644
index 0000000..63a912c
Binary files /dev/null and b/out/production/JavaIntro2Debrief/com/example/main/Main.class differ
diff --git a/src/com/example/bankaccount/BankAccount.java b/src/com/example/bankaccount/BankAccount.java
index e3070c9..ce4dbd1 100644
--- a/src/com/example/bankaccount/BankAccount.java
+++ b/src/com/example/bankaccount/BankAccount.java
@@ -1,6 +1,7 @@
package com.example.bankaccount;
public class BankAccount {
+
/*
RULES:
1. No direct souts in our methods, only returns
@@ -24,23 +25,59 @@ Class methods(return types):
/*
Instance field declarations should go here
balance(double), nameOnAccount(String), accountNumber(int), accountType(String)
- These fields should not be able to be manipulated or access outside this class!
- */
+ These fields should not be able to be manipulated or access outside this class!*/
+
+ private String nameOnAccount;
+ private double balance;
+ private int accountNumber;
+ private String accountType;
/*
Constructor method should go here
remember to take proper input for each instance field
then, assign that input to the appropriate field
*/
-
+ public BankAccount(String name, double balance, int number, String atype){
+ nameOnAccount = name;
+ this.balance = balance;
+ accountNumber = number;
+ accountType = atype;
+ }
/*
All your getter methods can go below
The return type for your getter methods depends on which instance field you are getting!
*/
-
-
+ //Getters
+ public String getName(){
+ return nameOnAccount;
+ }
+ public double getBalance(){
+ return balance;
+ }
+ public int getAccountNumber(){
+ return accountNumber;
+ }
+ public String getAccountType(){
+ return accountType;
+ }
+ //setters
+ public void setNameOnAccount(String nameOnAccount) {
+ this.nameOnAccount = nameOnAccount;
+ }
+
+ public void setBalance(double balance) {
+ this.balance = this.balance + balance;
+ }
+
+ public void setAccountNumber(int accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public void setAccountType(String accountType) {
+ this.accountType = accountType;
+ }
/*
Here you should write your withdraw method
requirements:
@@ -52,6 +89,21 @@ Class methods(return types):
5. return true if successful
otherwise, return false
*/
+ public boolean withdraw(double value){
+ double ischecking = this.accountType.equalsIgnoreCase("checking")?value+1.50:value ;
+ if (value < 0 || ischecking > this.balance ){
+ return false;
+ }
+ if (ischecking == value) {
+ this.balance = this.balance-value;
+ }else {this.balance = this.balance - ischecking;
+ }
+ System.out.println("Your balance now is: " + balance);
+ return true;
+
+
+ }
+
/*
@@ -62,7 +114,13 @@ Class methods(return types):
2. return true if successful
otherwise, return false
*/
-
+ public boolean deposit(double amout){
+ if(amout<0){
+ return false;
+ }
+ this.balance = this.balance+amout;
+ return true;
+ }
/*
Here you should write you toString method
@@ -70,6 +128,10 @@ Class methods(return types):
1. returns a String that represents all your instance field values
*/
+ public String toString() {
+ return "This account is owned by: " + getName() +" it is a "+ getAccountType() + " the account number is: "+ getAccountNumber() + " and the balance is " + getBalance();
+ }
+
}
diff --git a/src/com/example/main/Main.java b/src/com/example/main/Main.java
index 10c7f11..fe8e397 100644
--- a/src/com/example/main/Main.java
+++ b/src/com/example/main/Main.java
@@ -16,7 +16,9 @@ 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 Guilherme = new BankAccount("Guilherme", 100,2000,"Savings");
+ System.out.println(Guilherme.withdraw(50));
+ System.out.println(Guilherme.deposit(5.0));
+ System.out.println(Guilherme.getBalance());
}
}