From 3fea272becc862c4d69ce1daf8e969cd4ab7d2ff Mon Sep 17 00:00:00 2001 From: Guilherme dos Santos Date: Tue, 9 May 2023 18:50:56 -0500 Subject: [PATCH] Finall --- .idea/.name | 1 + .idea/compiler.xml | 6 ++ JavaIntro2Debrief.iml | 2 +- .../com/example/bankaccount/BankAccount.class | Bin 0 -> 2704 bytes .../com/example/main/Main.class | Bin 0 -> 867 bytes src/com/example/bankaccount/BankAccount.java | 74 ++++++++++++++++-- src/com/example/main/Main.java | 6 +- 7 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/compiler.xml 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/.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 0000000000000000000000000000000000000000..54f5d854d6d0abe7f87a1ff756a77daf8975aba3 GIT binary patch literal 2704 zcma)7S#KLv6#j0!#+fX2os>3EOcxxxiz$>su#4aL|XYSl{&UeoF&XPa>dGR}dv#=5vLMVo? zh6thp6OZJ&%-5y0lAo_UGIUoUdd9R&_nbgzCc8Y0IEG_LXc&Pea8S1!dE*P&Xx5E< zMOrnf>-L)E<}dMl(LW1}TC!oxTb=J@x$9-YZJE|eLE(;R7{`P_tRfkJZU~4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al 0 HcmV?d00001 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 0000000000000000000000000000000000000000..63a912c62f5e694fbe9a34e34258c977d488ffda GIT binary patch literal 867 zcmZ`%+iuf95Iviwacm5<&JA&IOCfGc&9w#6R-r_oN+}=(MQVB4IICofFOlQ4AifG7 zQVAqJfG55PF&kG35y20$J3Bk)oIReOzrXzeu#Fu9Da>d{o0vt0VeW_@bI0RB$9dB_ z5^l_p*^+^bcNk{Mc2h%^VaW}BM||Xd&l66I2OqfWhJzq>c4_}S*=J!e=&uIS>x#%1 znd$-Y(U-*q2Cc!5Wzgvx&@iW%=NasBeazj6BdS+wd;gxF8F$+eKVe9hYxbdm8@Q=q!Nek# z7;+PIP0@m817xrbW$W~0OVvWJ*hsYb|8JLlE(2$u0^N8KwyE)AT?XRyz;B7@9dCJbV%0;Jdrclmm7g7^vX8H(li)4ZlSk2(a9n^I<2o`C(&C=iL!2nUfXUP`4?SMOL?mSO?-X#Uif z0#g%6@d0HHt&G;$l~b@Uqw+(Fs;uH8ie_>FkFi0Sj!itF6V?2gyjGx_-=Q5?dLHNI zwO`ixQ?l$Utkpa&4RLvh>q&BJh}&n$5cUvv$8<$f1R6FAdHO>ItkJ-2pfsW{CKPyz TXLQHHG7MBm0K*pLDQy1%S|Pd= literal 0 HcmV?d00001 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()); } }