From fa4482a3154d8c742d1f4a54a8d4cc79d1388028 Mon Sep 17 00:00:00 2001 From: jcreate93 <84466621+jcreate93@users.noreply.github.com> Date: Mon, 21 Jun 2021 18:36:09 -0400 Subject: [PATCH 01/33] Updated Wage.java changed String Month; to String month; --- src/Wage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wage.java b/src/Wage.java index 777f173..239b789 100644 --- a/src/Wage.java +++ b/src/Wage.java @@ -2,7 +2,7 @@ public class Wage { String source; double amount; - String Month; + String month; //should add contructor(s) } From 70dca60ee2d43709dc6138fd945df25bfd69cbfc Mon Sep 17 00:00:00 2001 From: Joe Castro Date: Wed, 23 Jun 2021 11:10:03 -0400 Subject: [PATCH 02/33] testing remote repos adding commmit --- src/Wage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Wage.java b/src/Wage.java index 239b789..f7471c8 100644 --- a/src/Wage.java +++ b/src/Wage.java @@ -5,4 +5,5 @@ public class Wage { String month; //should add contructor(s) + //testing remote repos } From 6b4f2ab3bb5bfe4a999b761bc43ac5c4ec56cf39 Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Sun, 27 Jun 2021 15:10:02 -0400 Subject: [PATCH 03/33] added private variables and established setters and print method for them --- src/Expense.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Expense.java b/src/Expense.java index c386160..9fd8897 100644 --- a/src/Expense.java +++ b/src/Expense.java @@ -1,7 +1,17 @@ public class Expense { - String source; - double amount; - int yearlyfrequency; //1 for 1 time or once a year, 12 for monthly or or 24 for biweekly + private String source; + private double amount; + private int yearlyfrequency; //1 for 1 time or once a year, 12 for monthly or or 24 for biweekly + //should add contructor(s) + public void setAmount(double amount){ + this.amount = amount; + } + public void setSource(String source) { + this.source = source; + } + public void print() { + System.out.println(amount +"--"+ source); + } } From 6b4df377e91d495ccd3f44efa6a0d1db3b5db6e1 Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Sun, 27 Jun 2021 15:12:37 -0400 Subject: [PATCH 04/33] added yearlyFrequency setter --- src/Expense.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Expense.java b/src/Expense.java index 9fd8897..d8b345d 100644 --- a/src/Expense.java +++ b/src/Expense.java @@ -11,6 +11,9 @@ public void setAmount(double amount){ public void setSource(String source) { this.source = source; } + public void setYearlyFrequency(int yearlyFrequency) { + this.yearlyfrequency = yearlyFrequency; + } public void print() { System.out.println(amount +"--"+ source); } From 9df82b7bcfc909be974be30cc15b15c200244703 Mon Sep 17 00:00:00 2001 From: jcreate93 <84466621+jcreate93@users.noreply.github.com> Date: Mon, 28 Jun 2021 11:45:38 -0400 Subject: [PATCH 05/33] Created ExpenseCalculator Class --- src/ExpenseCalculator.java | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/ExpenseCalculator.java diff --git a/src/ExpenseCalculator.java b/src/ExpenseCalculator.java new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/ExpenseCalculator.java @@ -0,0 +1 @@ + From 51203c5fd7b08c8a1dc81ab59aac3da5a2aa4c43 Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Mon, 28 Jun 2021 12:29:15 -0400 Subject: [PATCH 06/33] added notes on function of classes --- src/EWalletApp.java | 10 ++++- src/Expense.java | 9 +++- src/ExpenseCalculator.java | 91 ++++++++++++++++++++++++++++++++++++++ src/Expenser.java | 76 ++++++++++++++++++------------- 4 files changed, 154 insertions(+), 32 deletions(-) create mode 100644 src/ExpenseCalculator.java diff --git a/src/EWalletApp.java b/src/EWalletApp.java index d6106ce..fc26f45 100644 --- a/src/EWalletApp.java +++ b/src/EWalletApp.java @@ -1,7 +1,15 @@ +/**This class is used for all GUI components, the login, and the main screen(list of options user can choose from). + * @author SENG 210 - Joseph Castro, Julie Chambers, Cameron Basham + */ + import java.util.ArrayList; +/*Teacher notes: + * this is the app class, has the GUI and create one object of your expense + * calculator class. The expense calculator class is the implementation of the Expenser interface + */ public class EWalletApp { - //this is the app class, has the GUI and create one object of your expense calculator class. The expense calculator class is the implementation of the Expenser interface + private ArrayList AllData; public void CreateUser(String username, String password) {} diff --git a/src/Expense.java b/src/Expense.java index c386160..347a2d0 100644 --- a/src/Expense.java +++ b/src/Expense.java @@ -1,7 +1,14 @@ +/**This class allows a user to enter an expense, its source, and designate how often the cost occurs(options include monthly,biweekly or yearly) + * + * @author SENG 210 - Joseph Castro, Julie Chambers, Cameron Basham + * + */ +import java.util.Scanner; public class Expense { String source; double amount; int yearlyfrequency; //1 for 1 time or once a year, 12 for monthly or or 24 for biweekly - //should add contructor(s) + + } diff --git a/src/ExpenseCalculator.java b/src/ExpenseCalculator.java new file mode 100644 index 0000000..f2cf3bc --- /dev/null +++ b/src/ExpenseCalculator.java @@ -0,0 +1,91 @@ +/** + * This class is used to implement the Expenser interface + * @author SENG 210 - Joseph Castro, Julie Chambers, Cameron Basham + * + */ +public class ExpenseCalculator implements Expenser{ + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + + @Override + public void addExpense(Expense Ex) { + // TODO Auto-generated method stub + + } + + @Override + public void addMonthlyIncome(Wage W) { + // TODO Auto-generated method stub + + } + + @Override + public void PrintFullreport() { + // TODO Auto-generated method stub + + } + + @Override + public void PrintExpensereport() { + // TODO Auto-generated method stub + + } + + @Override + public void PrintIncomereport() { + // TODO Auto-generated method stub + + } + + @Override + public void PrintIncomereportbyTpe() { + // TODO Auto-generated method stub + + } + + @Override + public void PrintExpensebyType() { + // TODO Auto-generated method stub + + } + + @Override + public void exportReport(String reportTitle) { + // TODO Auto-generated method stub + + } + + @Override + public Currency convertForeignCurrency(Currency C, double amount) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean loadExpenseFile(String filePath) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean loadIncomeFile(String filePath) { + // TODO Auto-generated method stub + return false; + } + + @Override + public int whenCanIBuy(String itemname, double price) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void updateMonthlySavings() { + // TODO Auto-generated method stub + + } + +} diff --git a/src/Expenser.java b/src/Expenser.java index 115e8a0..61bff20 100644 --- a/src/Expenser.java +++ b/src/Expenser.java @@ -1,36 +1,52 @@ +/**This class is the interface that stores the methods and variables needed to complete the software. + * @author SENG 210 - Joseph Castro, Julie Chambers, Cameron Basham + */ import java.util.ArrayList; - +/*Teacher notes: + * // As a user I'd like to add a monthly expense so I can track and report my expenses - 3pts + * // As a user I'd like to add a monthly income so I can track and report my income all year - 3pts + * //As a user I would like to view a detailed report of all expenses, income, and summary information + summary information include : total income, total income for each type, total income for each month, total expense, total expense for each type, + total savings (total income- total expenses) to date, if the total savings are less than zero it should be reported as total new debt. + //As a user I would like to view a detailed report of all expenses, and summary information for expenses + * //As a user I would like to view a detailed report of all income, and summary information for income + * //As a user I would like to view a detailed report of income of a certain type, and summary information for income + * //As a user I would like to view a detailed report of expense of a certain type , and summary information for expenses + * // As a user I would like to choose a report and export it as an external file (any type is fine preferences are csv or JSON) + * //As a user I would like to view my current balance in a different currency + Bonus : try to use the same convert function to convert from foreign currency to USD + * //As a user I would like to load multiple expenses from an external file all at once returning true if loaded successfully and false otherwise + * //As a user I would like to provide an item and a price and get an estimate in number of months needed to save up to buy this item. (based on current monthly saving. + * //updates monthly savings based on latest added income and expenses. This is an internal function not called by the users. Bonus: what is the most efficient way to call it (when?)? + */ public interface Expenser { public User userAtHand= null; - // As a user I'd like to add a monthly expense so I can track and report my expenses - 3pts - public void addExpense (Expense Ex); - // As a user I'd like to add a monthly income so I can track and report my income all year - 3pts - public void addMonthlyIncome (Wage W); - //As a user I would like to view a detailed report of all expenses, income, and summary information - //summary information include : total income, total income for each type, total income for each month, total expense, total expense for each type, - //total savings (total income- total expenses) to date, if the total savings are less than zero it should be reported as total new debt. - public void PrintFullreport(); - //As a user I would like to view a detailed report of all expenses, and summary information for expenses - public void PrintExpensereport(); - //As a user I would like to view a detailed report of all income, and summary information for income - public void PrintIncomereport(); - //As a user I would like to view a detailed report of income of a certain type, and summary information for income - public void PrintIncomereportbyTpe(); - //As a user I would like to view a detailed report of expense of a certain type , and summary information for expenses - public void PrintExpensebyType(); - // As a user I would like to choose a report and export it as an external file (any type is fine preferences are csv or JSON) - public void exportReport(String reportTitle); - // As a user I would like to view my current balance in a different currency - //Bonus : try to use the same convert function to convert from foreign currency to USD - public Currency convertForeignCurrency(Currency C, double amount); - // As a user I would like to load multiple expenses from an external file all at once returning true if loaded successfully and false otherwise - public boolean loadExpenseFile(String filePath); - // As a user I would like to load multiple income from an external file all at once returning true if loaded successfully and false otherwise - public boolean loadIncomeFile(String filePath); - // As a user I would like to provide an item and a price and get an estimate in number of months needed to save up to buy this item. (based on current monthly saving. - public int whenCanIBuy(String itemname,double price); - // updates monthly savings based on latest added income and expenses. This is an internal function not called by the users. Bonus: what is the most efficient way to call it (when?)? - public void updateMonthlySavings(); + + public void addExpense (Expense Ex); // As a user I'd like to add a monthly expense so I can track and report my expenses - 3pts + + public void addMonthlyIncome (Wage W); // As a user I'd like to add a monthly income so I can track and report my income all year - 3pts + + public void PrintFullreport(); //As a user I would like to view a detailed report of all expenses, income, and summary information summary information include : total income, total income for each type, total income for each month, total expense, total expense for each type, total savings (total income- total expenses) to date, if the total savings are less than zero it should be reported as total new debt. + + public void PrintExpensereport(); //As a user I would like to view a detailed report of all expenses, and summary information for expenses + + public void PrintIncomereport(); //As a user I would like to view a detailed report of all income, and summary information for income + + public void PrintIncomereportbyTpe(); //As a user I would like to view a detailed report of income of a certain type, and summary information for income + + public void PrintExpensebyType(); //As a user I would like to view a detailed report of expense of a certain type , and summary information for expenses + + public void exportReport(String reportTitle); // As a user I would like to choose a report and export it as an external file (any type is fine preferences are csv or JSON) + + public Currency convertForeignCurrency(Currency C, double amount); //As a user I would like to view my current balance in a different currency Bonus : try to use the same convert function to convert from foreign currency to USD + + public boolean loadExpenseFile(String filePath); //As a user I would like to load multiple expenses from an external file all at once returning true if loaded successfully and false otherwise + + public boolean loadIncomeFile(String filePath); // As a user I would like to load multiple income from an external file all at once returning true if loaded successfully and false otherwise + + public int whenCanIBuy(String itemname,double price);// As a user I would like to provide an item and a price and get an estimate in number of months needed to save up to buy this item. (based on current monthly saving. + + public void updateMonthlySavings(); // updates monthly savings based on latest added income and expenses. This is an internal function not called by the users. Bonus: what is the most efficient way to call it (when?)? } From cfb8b34e6b91a326311447b615d041c20e0d48c8 Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Mon, 28 Jun 2021 14:40:32 -0400 Subject: [PATCH 07/33] removed <<>>>>>> branch 'master' of https://github.com/jcreate93/Ewallet-SENG210.git + + From 4e7ec490bd79d4c4c13e690e0a4661bffc50ad26 Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Mon, 28 Jun 2021 15:07:20 -0400 Subject: [PATCH 08/33] got rid of teacher notes in Expenser.java --- src/Expenser.java | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/Expenser.java b/src/Expenser.java index 61bff20..857349d 100644 --- a/src/Expenser.java +++ b/src/Expenser.java @@ -2,24 +2,9 @@ * @author SENG 210 - Joseph Castro, Julie Chambers, Cameron Basham */ import java.util.ArrayList; -/*Teacher notes: - * // As a user I'd like to add a monthly expense so I can track and report my expenses - 3pts - * // As a user I'd like to add a monthly income so I can track and report my income all year - 3pts - * //As a user I would like to view a detailed report of all expenses, income, and summary information - summary information include : total income, total income for each type, total income for each month, total expense, total expense for each type, - total savings (total income- total expenses) to date, if the total savings are less than zero it should be reported as total new debt. - //As a user I would like to view a detailed report of all expenses, and summary information for expenses - * //As a user I would like to view a detailed report of all income, and summary information for income - * //As a user I would like to view a detailed report of income of a certain type, and summary information for income - * //As a user I would like to view a detailed report of expense of a certain type , and summary information for expenses - * // As a user I would like to choose a report and export it as an external file (any type is fine preferences are csv or JSON) - * //As a user I would like to view my current balance in a different currency - Bonus : try to use the same convert function to convert from foreign currency to USD - * //As a user I would like to load multiple expenses from an external file all at once returning true if loaded successfully and false otherwise - * //As a user I would like to provide an item and a price and get an estimate in number of months needed to save up to buy this item. (based on current monthly saving. - * //updates monthly savings based on latest added income and expenses. This is an internal function not called by the users. Bonus: what is the most efficient way to call it (when?)? - */ + public interface Expenser { + public User userAtHand= null; public void addExpense (Expense Ex); // As a user I'd like to add a monthly expense so I can track and report my expenses - 3pts From b69fcc5dd70694e5e38a758097766fbdf89f7e2b Mon Sep 17 00:00:00 2001 From: cam Date: Mon, 28 Jun 2021 19:13:35 -0400 Subject: [PATCH 09/33] testing --- src/Expense.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Expense.java b/src/Expense.java index c386160..bde39cf 100644 --- a/src/Expense.java +++ b/src/Expense.java @@ -5,3 +5,6 @@ public class Expense { int yearlyfrequency; //1 for 1 time or once a year, 12 for monthly or or 24 for biweekly //should add contructor(s) } + + +///// Cameron testing collab out. \ No newline at end of file From ac31f96c8da6e233b8e7767192141ba66faeb80e Mon Sep 17 00:00:00 2001 From: cam Date: Mon, 28 Jun 2021 19:43:55 -0400 Subject: [PATCH 10/33] Adding a currency method --- src/Currency.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Currency.java b/src/Currency.java index c5b6c8b..d2a8935 100644 --- a/src/Currency.java +++ b/src/Currency.java @@ -2,5 +2,27 @@ public class Currency { public double rate; public String name; + // Current Rates as of 6/68/2021 + public double Euro_rate = 0.84; + public double BritishPound_rate = 0.72; + public double IndianRupee_rate = 0.74; + public double AustralianDollar_rate = 1.32; + public double CanadianDollar_rate = 1.23; + + public double set_rate(int selection_num) { + double rate; + + //sets the rate to Euros + if (selection_num == 0) { + rate = Euro_rate; + } + + if (selection_num == 1) { + rate = BritishPound_rate; + } + + + + } } From 7c33cd0a4ad335beac0a8547552da75e8bf93ccb Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Wed, 30 Jun 2021 08:54:48 -0400 Subject: [PATCH 11/33] added setters and getters as well as checks for correct input --- src/Expense.java | 97 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 5 deletions(-) diff --git a/src/Expense.java b/src/Expense.java index d8b345d..0f89bd4 100644 --- a/src/Expense.java +++ b/src/Expense.java @@ -2,19 +2,106 @@ public class Expense { private String source; private double amount; - private int yearlyfrequency; //1 for 1 time or once a year, 12 for monthly or or 24 for biweekly + private int yearlyFrequency; //1 for 1 time or once a year, 12 for monthly or or 24 for biweekly + + boolean foundDigit = false; + boolean foundUpperCase = false; + boolean foundLowerCase = false; + boolean foundSymbol = false; + boolean foundLength = false; + boolean foundMonthly = false; + boolean foundYearly = false; + boolean foundBiweekly = false; + + //should add contructor(s) + + //setters public void setAmount(double amount){ + /*README for (int i = 0; i <= amount; ++i) { + if (amount.isDigit()) { + foundDigit = true; + + } + }*/ this.amount = amount; } public void setSource(String source) { - this.source = source; + for (int i = 0; i < source.length(); ++i) { + + //checks if lowercase letters are present + if (source.charAt(i) >= 'a' && source.charAt(i) <= 'z') { + foundLowerCase = true; + } + + //checks if uppercase letters present + else if (source.charAt(i) >= 'A' && source.charAt(i) <= 'Z') { + foundUpperCase = true; + } + + //checks if there are any digits present + else if (Character.isDigit(source.charAt(i))) { + foundDigit = true; + } + + //verifies that the input is letters only + else if (foundLowerCase || foundUpperCase || foundDigit) { + this.source = source; + } + + else { + System.out.println("Source can only contain numbers, uppercase letters, or lowercase letters"); + } + } + + + + + + + } public void setYearlyFrequency(int yearlyFrequency) { - this.yearlyfrequency = yearlyFrequency; + + //checking for monthly + if (yearlyFrequency == 12) { + foundMonthly = true; + } + + //checking for yearly + else if (yearlyFrequency == 1) { + foundYearly = true; + } + + //checking for biweekly + else if (yearlyFrequency == 24) { + foundBiweekly = true; + } + + //checking to make sure only 1, 12, or 24 is entered + else if (foundMonthly || foundYearly || foundBiweekly) { + this.yearlyFrequency = yearlyFrequency; + } + else { + System.out.println("You can only enter the numbers 1, 12, or 24 for your expense occurance."); + } + } - public void print() { - System.out.println(amount +"--"+ source); + + //getters + public double getAmount() { + return amount; + } + public String getSource() { + return source; + } + public int getYearlyFrequency() { + return yearlyFrequency; + } + + + public void printExpense() { + System.out.println(amount +"--"+ source + "--" + yearlyFrequency); } } From 2175a07207915f12bbec7194220b39c9abdde2fe Mon Sep 17 00:00:00 2001 From: cam Date: Wed, 30 Jun 2021 13:19:17 -0400 Subject: [PATCH 12/33] Created a currency class --- src/Currency.java | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/Currency.java b/src/Currency.java index d2a8935..4c8e8d8 100644 --- a/src/Currency.java +++ b/src/Currency.java @@ -1,28 +1,20 @@ public class Currency { - public double rate; - public String name; - // Current Rates as of 6/68/2021 - public double Euro_rate = 0.84; - public double BritishPound_rate = 0.72; - public double IndianRupee_rate = 0.74; - public double AustralianDollar_rate = 1.32; - public double CanadianDollar_rate = 1.23; - - - public double set_rate(int selection_num) { - double rate; - - //sets the rate to Euros - if (selection_num == 0) { - rate = Euro_rate; - } - - if (selection_num == 1) { - rate = BritishPound_rate; - } - - - + public double rate = 0; + public String name = ""; + + public String getCurrency() { + return "Rate: " + this.rate + ", Name: " + this.name; } + public double getRate() { + return this.rate; + } + public String getName() { + return this.name; + } + + public Currency(double rate, String name) { + this.rate = rate; + this.name = name; + } } From 2795d03c4ea73195f8c75c18928056501da12645 Mon Sep 17 00:00:00 2001 From: Joe Castro Date: Wed, 30 Jun 2021 20:12:44 -0400 Subject: [PATCH 13/33] added monthlysavings constructors under user class --- src/ExpenseCalculator.java | 1 + src/User.java | 14 ++++++++++++++ src/Wage.java | 1 - 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ExpenseCalculator.java b/src/ExpenseCalculator.java index 3a304ef..6b6d842 100644 --- a/src/ExpenseCalculator.java +++ b/src/ExpenseCalculator.java @@ -87,6 +87,7 @@ public int whenCanIBuy(String itemname, double price) { public void updateMonthlySavings() { // TODO Auto-generated method stub + } } diff --git a/src/User.java b/src/User.java index 8327a21..1375884 100644 --- a/src/User.java +++ b/src/User.java @@ -4,6 +4,7 @@ public class User { private ArrayList currencyRates; private ArrayList Income; // user income sources that user can record or view or search by type or month private ArrayList Spending; //user's expenses + private double updatedsavings; String username; String pwd; //current total income - total @@ -11,5 +12,18 @@ public class User { // possible monthly savings, calculated using monthly income (most recent) assuming the data we have is for one year, and monthly and biweekly expenses, here you can assume yearly expenses that are recorded have already been paid. double monthlysavings; //should add constructor(s) + public User() { + this.updatedsavings = 0; + } + public void setSavings(double updatedsavings) { + this.updatedsavings = monthlysavings; + } + public void getSavings() { + return Income - Spending; + } + public void print() { + System.out.println(this.monthlysavings + " saved this month!"); + } + User(String username,String password){} } diff --git a/src/Wage.java b/src/Wage.java index f7471c8..239b789 100644 --- a/src/Wage.java +++ b/src/Wage.java @@ -5,5 +5,4 @@ public class Wage { String month; //should add contructor(s) - //testing remote repos } From adc8c07e75d45e7dd4c842d8538359df419389f1 Mon Sep 17 00:00:00 2001 From: cam Date: Thu, 1 Jul 2021 12:40:12 -0400 Subject: [PATCH 14/33] Solid starting poiint after meeting with Professor --- src/Currency.java | 4 +-- src/EWalletApp.java | 56 ++++++++++++++++++++++++++++++++++++-- src/Expense.java | 7 ++--- src/ExpenseCalculator.java | 25 +++++++++++++---- src/Expenser.java | 1 - src/User.java | 22 ++++++++++----- 6 files changed, 94 insertions(+), 21 deletions(-) diff --git a/src/Currency.java b/src/Currency.java index 4c8e8d8..318825d 100644 --- a/src/Currency.java +++ b/src/Currency.java @@ -1,7 +1,7 @@ public class Currency { - public double rate = 0; - public String name = ""; + private double rate = 0; + private String name = ""; public String getCurrency() { return "Rate: " + this.rate + ", Name: " + this.name; diff --git a/src/EWalletApp.java b/src/EWalletApp.java index fc26f45..13cb7ea 100644 --- a/src/EWalletApp.java +++ b/src/EWalletApp.java @@ -1,7 +1,7 @@ /**This class is used for all GUI components, the login, and the main screen(list of options user can choose from). * @author SENG 210 - Joseph Castro, Julie Chambers, Cameron Basham */ - +import java.util.Scanner; import java.util.ArrayList; /*Teacher notes: * this is the app class, has the GUI and create one object of your expense @@ -10,7 +10,59 @@ public class EWalletApp { - private ArrayList AllData; + private static ArrayList AllData = new ArrayList(); + public void CreateUser(String username, String password) {} + public static ExpenseCalculator brain = new ExpenseCalculator(); + + + + + public static void main(String[] args) { + + System.out.println("whats is your name"); + String name = ""; + Scanner scnr = new Scanner(System.in); + + + name = scnr.next(); + + for (User u : AllData) { + if (u.username.equals(name)) { + brain.userAtHand = u; + } + + + } + + if (brain.userAtHand == null) { + User u1 = new User(); + u1.username = name; + AllData.add(u1); + brain.userAtHand = u1; + + } + //add eve3nt handler + Expense e1 = new Expense(); + + System.out.println("enter the source"); + e1.source = scnr.next(); + + System.out.println("enter amount"); + e1.amount = scnr.nextDouble(); + + System.out.println("yearly frequency"); + e1.yearlyfrequency = scnr.nextInt(); + + //adding expense + brain.addExpense(e1); + brain.userAtHand.printExpenses(); + + //adding monthly income + //brain.addMonthlyIncome(null); + + + } + } diff --git a/src/Expense.java b/src/Expense.java index 3d7ab37..1f70cf6 100644 --- a/src/Expense.java +++ b/src/Expense.java @@ -10,8 +10,7 @@ public class Expense { double amount; int yearlyfrequency; //1 for 1 time or once a year, 12 for monthly or or 24 for biweekly - + public String toString() { + return "Source: " + source + "Amount: " + amount + "Yearly Frequency: " + yearlyfrequency; + } } - - -///// Cameron testing collab out. \ No newline at end of file diff --git a/src/ExpenseCalculator.java b/src/ExpenseCalculator.java index 6b6d842..ba31147 100644 --- a/src/ExpenseCalculator.java +++ b/src/ExpenseCalculator.java @@ -4,16 +4,31 @@ * @author SENG 210 - Joseph Castro, Julie Chambers, Cameron Basham * */ -public class ExpenseCalculator implements Expenser{ - public static void main(String[] args) { - // TODO Auto-generated method stub - } +public class ExpenseCalculator implements Expenser{ + + + // Current Rates as of 6/68/2021 + private double Euro_rate = 0.84; + private double BritishPound_rate = 0.72; + private double IndianRupee_rate = 0.74; + private double AustralianDollar_rate = 1.32; + private double CanadianDollar_rate = 1.23; + + Currency Dollars = new Currency(1.0, "Dollars"); + Currency Euros = new Currency(Euro_rate, "Euros"); + Currency Pounds = new Currency(BritishPound_rate, "Pounds"); + Currency Rupees = new Currency(IndianRupee_rate, "Rupees"); + Currency AU_Dollars = new Currency(AustralianDollar_rate, "Australian Dollars"); + Currency CA_Dollars = new Currency(CanadianDollar_rate, "Canadian Dollars"); + + public User userAtHand; + @Override public void addExpense(Expense Ex) { - // TODO Auto-generated method stub + userAtHand.Spending.add(Ex); } diff --git a/src/Expenser.java b/src/Expenser.java index 61bff20..acbf17d 100644 --- a/src/Expenser.java +++ b/src/Expenser.java @@ -20,7 +20,6 @@ total savings (total income- total expenses) to date, if the total savings are l * //updates monthly savings based on latest added income and expenses. This is an internal function not called by the users. Bonus: what is the most efficient way to call it (when?)? */ public interface Expenser { -public User userAtHand= null; public void addExpense (Expense Ex); // As a user I'd like to add a monthly expense so I can track and report my expenses - 3pts diff --git a/src/User.java b/src/User.java index 1375884..f3cb10e 100644 --- a/src/User.java +++ b/src/User.java @@ -1,12 +1,15 @@ import java.util.ArrayList; public class User { - private ArrayList currencyRates; - private ArrayList Income; // user income sources that user can record or view or search by type or month - private ArrayList Spending; //user's expenses + private ArrayList currencyRates = new ArrayList(); + private ArrayList Income = new ArrayList(); // user income sources that user can record or view or search by type or month + public ArrayList Spending = new ArrayList(); //user's expenses + private double updatedsavings; + String username; String pwd; + //current total income - total double balance; // possible monthly savings, calculated using monthly income (most recent) assuming the data we have is for one year, and monthly and biweekly expenses, here you can assume yearly expenses that are recorded have already been paid. @@ -18,12 +21,17 @@ public User() { public void setSavings(double updatedsavings) { this.updatedsavings = monthlysavings; } - public void getSavings() { - return Income - Spending; - } - public void print() { + //public void getSavings() { + //return Income - Spending; + //} + public void printExpenses() { System.out.println(this.monthlysavings + " saved this month!"); + + for (Expense e : Spending) { + System.out.print(e); + } } + User(String username,String password){} } From 78b544c0151d8610a7f1d3676ef502dd6257eeec Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Thu, 1 Jul 2021 12:56:08 -0400 Subject: [PATCH 15/33] updated Expense.java --- src/Expense.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/Expense.java b/src/Expense.java index 4d72e3b..8a0d897 100644 --- a/src/Expense.java +++ b/src/Expense.java @@ -6,13 +6,6 @@ import java.util.Scanner; public class Expense { -<<<<<<< HEAD - String source; - double amount; - int yearlyfrequency; //1 for 1 time or once a year, 12 for monthly or or 24 for biweekly - - -======= private String source; private double amount; private int yearlyFrequency; //1 for 1 time or once a year, 12 for monthly or or 24 for biweekly @@ -117,8 +110,4 @@ public int getYearlyFrequency() { public void printExpense() { System.out.println(amount +"--"+ source + "--" + yearlyFrequency); } ->>>>>>> refs/heads/issue9AddMonthlyIncome } - - -///// Cameron testing collab out. \ No newline at end of file From 5884d6676c1035b99faccfd8148db5c420d1c0c9 Mon Sep 17 00:00:00 2001 From: jcreate93 <84466621+jcreate93@users.noreply.github.com> Date: Sun, 4 Jul 2021 13:13:30 -0400 Subject: [PATCH 16/33] Created MyFrame.java Added a seperate JFrame class from EWalletApp --- src/MyFrame.java | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/MyFrame.java diff --git a/src/MyFrame.java b/src/MyFrame.java new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/MyFrame.java @@ -0,0 +1 @@ + From 5c3e77775d92b7ba7b17d8b9b2234119c627867f Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Sun, 4 Jul 2021 15:23:55 -0400 Subject: [PATCH 17/33] added main screen GUI to MyFrame.java --- src/MyFrame.java | 152 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/src/MyFrame.java b/src/MyFrame.java index 8b13789..d59c9c6 100644 --- a/src/MyFrame.java +++ b/src/MyFrame.java @@ -1 +1,153 @@ +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.NumberFormat; +import java.util.Scanner; +import javax.swing.JButton; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JTextField; +import javax.swing.JLabel; +import java.awt.Insets; +import java.awt.GridLayout; +import java.awt.BorderLayout; +import javax.swing.BoxLayout; +import javax.swing.JRadioButton; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.GroupLayout; +import javax.swing.GroupLayout.Alignment; +import javax.swing.LayoutStyle.ComponentPlacement; + +public class MyFrame extends JFrame implements ActionListener{ + //initialize variables + String firstName; + private JTextField firstNameField; + private JTextField userNameField; + private JTextField passwordField; + + +MyFrame(){ + + + //initialize GUI components + + JLabel firstNameLabel; + JButton nextButton; + + + Scanner scnr = new Scanner(System.in); + + + //create JFrame window + setTitle("Bank app"); + this.setSize(420, 360); + + //jpanel + JPanel mainPanel = new JPanel(); + + + + + + + + GridBagLayout gbl_mainPanel = new GridBagLayout(); + gbl_mainPanel.columnWidths = new int[]{93, 50, 104, 56, 0}; + gbl_mainPanel.rowHeights = new int[]{19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + gbl_mainPanel.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE}; + gbl_mainPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; + mainPanel.setLayout(gbl_mainPanel); + getContentPane().add(mainPanel); + + //welcomeLabel + JLabel welcomeLabel = new JLabel("Welcome to Bank App!"); + welcomeLabel.setHorizontalAlignment(SwingConstants.TRAILING); + GridBagConstraints gbc_welcomeLabel = new GridBagConstraints(); + gbc_welcomeLabel.gridwidth = 2; + gbc_welcomeLabel.insets = new Insets(0, 0, 5, 5); + gbc_welcomeLabel.gridx = 1; + gbc_welcomeLabel.gridy = 1; + mainPanel.add(welcomeLabel, gbc_welcomeLabel); + + + //firstNameLabel + firstNameLabel = new JLabel("Enter your first name: "); + GridBagConstraints gbc_firstNameLabel = new GridBagConstraints(); + gbc_firstNameLabel.anchor = GridBagConstraints.WEST; + gbc_firstNameLabel.insets = new Insets(0, 0, 5, 5); + gbc_firstNameLabel.gridx = 1; + gbc_firstNameLabel.gridy = 3; + mainPanel.add(firstNameLabel, gbc_firstNameLabel); + + + //firstNameField + firstNameField = new JTextField(); + GridBagConstraints gbc_firstNameField = new GridBagConstraints(); + gbc_firstNameField.insets = new Insets(0, 0, 5, 5); + gbc_firstNameField.fill = GridBagConstraints.HORIZONTAL; + gbc_firstNameField.gridx = 2; + gbc_firstNameField.gridy = 3; + mainPanel.add(firstNameField, gbc_firstNameField); + firstNameField.setColumns(10); + + JLabel userNameLabel = new JLabel("Username:"); + GridBagConstraints gbc_userNameLabel = new GridBagConstraints(); + gbc_userNameLabel.anchor = GridBagConstraints.EAST; + gbc_userNameLabel.insets = new Insets(0, 0, 5, 5); + gbc_userNameLabel.gridx = 1; + gbc_userNameLabel.gridy = 4; + mainPanel.add(userNameLabel, gbc_userNameLabel); + + userNameField = new JTextField(); + GridBagConstraints gbc_userNameField = new GridBagConstraints(); + gbc_userNameField.insets = new Insets(0, 0, 5, 5); + gbc_userNameField.fill = GridBagConstraints.HORIZONTAL; + gbc_userNameField.gridx = 2; + gbc_userNameField.gridy = 4; + mainPanel.add(userNameField, gbc_userNameField); + userNameField.setColumns(10); + + JLabel passwordLabel = new JLabel("Password:"); + GridBagConstraints gbc_passwordLabel = new GridBagConstraints(); + gbc_passwordLabel.anchor = GridBagConstraints.EAST; + gbc_passwordLabel.insets = new Insets(0, 0, 5, 5); + gbc_passwordLabel.gridx = 1; + gbc_passwordLabel.gridy = 5; + mainPanel.add(passwordLabel, gbc_passwordLabel); + + passwordField = new JTextField(); + GridBagConstraints gbc_passwordField = new GridBagConstraints(); + gbc_passwordField.insets = new Insets(0, 0, 5, 5); + gbc_passwordField.fill = GridBagConstraints.HORIZONTAL; + gbc_passwordField.gridx = 2; + gbc_passwordField.gridy = 5; + mainPanel.add(passwordField, gbc_passwordField); + passwordField.setColumns(10); + + //next button + nextButton = new JButton("Next"); + nextButton.setFocusable(false); + nextButton.addActionListener(this); + GridBagConstraints gbc_nextButton = new GridBagConstraints(); + gbc_nextButton.insets = new Insets(0, 0, 5, 5); + gbc_nextButton.gridx = 2; + gbc_nextButton.gridy = 7; + mainPanel.add(nextButton, gbc_nextButton); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setVisible(true); + + + } + + @Override + public void actionPerformed(ActionEvent event) { + firstName = nameField.getText(); + System.out.println(firstName); + + + } + +} From 9229b8685beb71b4d964b442f7150874a30cd438 Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Wed, 7 Jul 2021 12:19:15 -0400 Subject: [PATCH 18/33] updated files --- src/EWalletApp.java | 19 +++++++++++++------ src/Expenser.java | 6 +++--- src/MyFrame.java | 40 +++++++++++++++++++++------------------- src/checkLogin.txt | 6 ++++++ 4 files changed, 43 insertions(+), 28 deletions(-) create mode 100644 src/checkLogin.txt diff --git a/src/EWalletApp.java b/src/EWalletApp.java index 13cb7ea..db9e947 100644 --- a/src/EWalletApp.java +++ b/src/EWalletApp.java @@ -3,6 +3,11 @@ */ import java.util.Scanner; import java.util.ArrayList; +import javax.swing.JFrame; +import javax.swing.JTextField; + + + /*Teacher notes: * this is the app class, has the GUI and create one object of your expense * calculator class. The expense calculator class is the implementation of the Expenser interface @@ -16,12 +21,14 @@ public void CreateUser(String username, String password) {} public static ExpenseCalculator brain = new ExpenseCalculator(); - - + public static void main(String[] args) { - System.out.println("whats is your name"); + MyFrame mainFrame = new MyFrame(); + + //user enters name + System.out.println("What is your name?"); String name = ""; Scanner scnr = new Scanner(System.in); @@ -47,13 +54,13 @@ public static void main(String[] args) { Expense e1 = new Expense(); System.out.println("enter the source"); - e1.source = scnr.next(); + //e1.source = scnr.next(); System.out.println("enter amount"); - e1.amount = scnr.nextDouble(); + //e1.amount = scnr.nextDouble(); System.out.println("yearly frequency"); - e1.yearlyfrequency = scnr.nextInt(); + //e1.yearlyFrequency = scnr.nextInt(); //adding expense brain.addExpense(e1); diff --git a/src/Expenser.java b/src/Expenser.java index 88812e5..0c3d1e2 100644 --- a/src/Expenser.java +++ b/src/Expenser.java @@ -4,11 +4,11 @@ import java.util.ArrayList; public interface Expenser { -<<<<<<< HEAD + public User userAtHand= null; -======= ->>>>>>> branch 'master' of https://github.com/jcreate93/Ewallet-SENG210.git + + public void addExpense (Expense Ex); // As a user I'd like to add a monthly expense so I can track and report my expenses - 3pts diff --git a/src/MyFrame.java b/src/MyFrame.java index d59c9c6..f1f78ab 100644 --- a/src/MyFrame.java +++ b/src/MyFrame.java @@ -23,7 +23,9 @@ public class MyFrame extends JFrame implements ActionListener{ //initialize variables - String firstName; + private String firstName; + private String userName; + private String password; private JTextField firstNameField; private JTextField userNameField; private JTextField passwordField; @@ -33,27 +35,16 @@ public class MyFrame extends JFrame implements ActionListener{ //initialize GUI components - JLabel firstNameLabel; JButton nextButton; - Scanner scnr = new Scanner(System.in); - - //create JFrame window setTitle("Bank app"); this.setSize(420, 360); - //jpanel + //mainPanel JPanel mainPanel = new JPanel(); - - - - - - - GridBagLayout gbl_mainPanel = new GridBagLayout(); gbl_mainPanel.columnWidths = new int[]{93, 50, 104, 56, 0}; gbl_mainPanel.rowHeights = new int[]{19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -62,7 +53,7 @@ public class MyFrame extends JFrame implements ActionListener{ mainPanel.setLayout(gbl_mainPanel); getContentPane().add(mainPanel); - //welcomeLabel + //welcomeLabel JLabel welcomeLabel = new JLabel("Welcome to Bank App!"); welcomeLabel.setHorizontalAlignment(SwingConstants.TRAILING); GridBagConstraints gbc_welcomeLabel = new GridBagConstraints(); @@ -73,7 +64,7 @@ public class MyFrame extends JFrame implements ActionListener{ mainPanel.add(welcomeLabel, gbc_welcomeLabel); - //firstNameLabel + //firstNameLabel firstNameLabel = new JLabel("Enter your first name: "); GridBagConstraints gbc_firstNameLabel = new GridBagConstraints(); gbc_firstNameLabel.anchor = GridBagConstraints.WEST; @@ -83,7 +74,7 @@ public class MyFrame extends JFrame implements ActionListener{ mainPanel.add(firstNameLabel, gbc_firstNameLabel); - //firstNameField + //firstNameField firstNameField = new JTextField(); GridBagConstraints gbc_firstNameField = new GridBagConstraints(); gbc_firstNameField.insets = new Insets(0, 0, 5, 5); @@ -93,6 +84,7 @@ public class MyFrame extends JFrame implements ActionListener{ mainPanel.add(firstNameField, gbc_firstNameField); firstNameField.setColumns(10); + //userNameLabel JLabel userNameLabel = new JLabel("Username:"); GridBagConstraints gbc_userNameLabel = new GridBagConstraints(); gbc_userNameLabel.anchor = GridBagConstraints.EAST; @@ -101,6 +93,7 @@ public class MyFrame extends JFrame implements ActionListener{ gbc_userNameLabel.gridy = 4; mainPanel.add(userNameLabel, gbc_userNameLabel); + //userNameField userNameField = new JTextField(); GridBagConstraints gbc_userNameField = new GridBagConstraints(); gbc_userNameField.insets = new Insets(0, 0, 5, 5); @@ -110,6 +103,7 @@ public class MyFrame extends JFrame implements ActionListener{ mainPanel.add(userNameField, gbc_userNameField); userNameField.setColumns(10); + //passwordLabel JLabel passwordLabel = new JLabel("Password:"); GridBagConstraints gbc_passwordLabel = new GridBagConstraints(); gbc_passwordLabel.anchor = GridBagConstraints.EAST; @@ -118,6 +112,7 @@ public class MyFrame extends JFrame implements ActionListener{ gbc_passwordLabel.gridy = 5; mainPanel.add(passwordLabel, gbc_passwordLabel); + //passwordField passwordField = new JTextField(); GridBagConstraints gbc_passwordField = new GridBagConstraints(); gbc_passwordField.insets = new Insets(0, 0, 5, 5); @@ -127,7 +122,7 @@ public class MyFrame extends JFrame implements ActionListener{ mainPanel.add(passwordField, gbc_passwordField); passwordField.setColumns(10); - //next button + //next button nextButton = new JButton("Next"); nextButton.setFocusable(false); nextButton.addActionListener(this); @@ -139,14 +134,21 @@ public class MyFrame extends JFrame implements ActionListener{ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); - } @Override public void actionPerformed(ActionEvent event) { - firstName = nameField.getText(); + + firstName = firstNameField.getText(); System.out.println(firstName); + userName = userNameField.getText(); + System.out.println(userName); + + password = passwordField.getText(); + System.out.println(password); + + } diff --git a/src/checkLogin.txt b/src/checkLogin.txt new file mode 100644 index 0000000..38ba80d --- /dev/null +++ b/src/checkLogin.txt @@ -0,0 +1,6 @@ +User1111 +Password1111 +User2222 +Password2222 +User3333 +Password3333 \ No newline at end of file From e8698d6ada96934c58ff7bfaa306381ac36d8a39 Mon Sep 17 00:00:00 2001 From: cam Date: Wed, 7 Jul 2021 17:56:42 -0400 Subject: [PATCH 19/33] Added functionality to convert balance to foreign Currency --- src/ExpenseCalculator.java | 29 ++++++++++++++--------------- src/Expenser.java | 4 +++- src/User.java | 26 +++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/ExpenseCalculator.java b/src/ExpenseCalculator.java index ba31147..30e5af2 100644 --- a/src/ExpenseCalculator.java +++ b/src/ExpenseCalculator.java @@ -9,19 +9,6 @@ public class ExpenseCalculator implements Expenser{ - // Current Rates as of 6/68/2021 - private double Euro_rate = 0.84; - private double BritishPound_rate = 0.72; - private double IndianRupee_rate = 0.74; - private double AustralianDollar_rate = 1.32; - private double CanadianDollar_rate = 1.23; - - Currency Dollars = new Currency(1.0, "Dollars"); - Currency Euros = new Currency(Euro_rate, "Euros"); - Currency Pounds = new Currency(BritishPound_rate, "Pounds"); - Currency Rupees = new Currency(IndianRupee_rate, "Rupees"); - Currency AU_Dollars = new Currency(AustralianDollar_rate, "Australian Dollars"); - Currency CA_Dollars = new Currency(CanadianDollar_rate, "Canadian Dollars"); public User userAtHand; @@ -75,9 +62,21 @@ public void exportReport(String reportTitle) { } @Override - public Currency convertForeignCurrency(Currency C, double amount) { + public double convertForeignCurrency(String Currency_Name, double amount) { + for (Currency c : userAtHand.currencyRates) { + if (c.getName().equals(Currency_Name)) { + return amount * c.getRate(); + } + } + // TODO Auto-generated method stub - return null; + return -1; + // return a error message exception + } + + public double convertForeignCurrency(String Currency_Name) { + return convertForeignCurrency (Currency_Name, userAtHand.balance); + //return null; } @Override diff --git a/src/Expenser.java b/src/Expenser.java index 0c3d1e2..6b4dec2 100644 --- a/src/Expenser.java +++ b/src/Expenser.java @@ -26,7 +26,7 @@ public interface Expenser { public void exportReport(String reportTitle); // As a user I would like to choose a report and export it as an external file (any type is fine preferences are csv or JSON) - public Currency convertForeignCurrency(Currency C, double amount); //As a user I would like to view my current balance in a different currency Bonus : try to use the same convert function to convert from foreign currency to USD + //public Currency convertForeignCurrency(Currency C, double amount); //As a user I would like to view my current balance in a different currency Bonus : try to use the same convert function to convert from foreign currency to USD public boolean loadExpenseFile(String filePath); //As a user I would like to load multiple expenses from an external file all at once returning true if loaded successfully and false otherwise @@ -35,6 +35,8 @@ public interface Expenser { public int whenCanIBuy(String itemname,double price);// As a user I would like to provide an item and a price and get an estimate in number of months needed to save up to buy this item. (based on current monthly saving. public void updateMonthlySavings(); // updates monthly savings based on latest added income and expenses. This is an internal function not called by the users. Bonus: what is the most efficient way to call it (when?)? + + double convertForeignCurrency(String Currency_Name, double amount); } diff --git a/src/User.java b/src/User.java index f3cb10e..89b0253 100644 --- a/src/User.java +++ b/src/User.java @@ -1,7 +1,24 @@ import java.util.ArrayList; public class User { - private ArrayList currencyRates = new ArrayList(); + public ArrayList currencyRates = new ArrayList(); + + + // Current Rates as of 6/68/2021 + private double Euro_rate = 0.84; + private double BritishPound_rate = 0.72; + private double IndianRupee_rate = 0.74; + private double AustralianDollar_rate = 1.32; + private double CanadianDollar_rate = 1.23; + + Currency Dollars = new Currency(1.0, "Dollars"); + Currency Euros = new Currency(Euro_rate, "Euros"); + Currency Pounds = new Currency(BritishPound_rate, "Pounds"); + Currency Rupees = new Currency(IndianRupee_rate, "Rupees"); + Currency AU_Dollars = new Currency(AustralianDollar_rate, "Australian Dollars"); + Currency CA_Dollars = new Currency(CanadianDollar_rate, "Canadian Dollars"); + + private ArrayList Income = new ArrayList(); // user income sources that user can record or view or search by type or month public ArrayList Spending = new ArrayList(); //user's expenses @@ -16,6 +33,13 @@ public class User { double monthlysavings; //should add constructor(s) public User() { + currencyRates.add(Dollars); + currencyRates.add(Euros); + currencyRates.add(Pounds); + currencyRates.add(Rupees); + currencyRates.add(AU_Dollars); + currencyRates.add(CA_Dollars); + //add other Currency this.updatedsavings = 0; } public void setSavings(double updatedsavings) { From 82cecda14f4bdd18e6da90e6035229653b9ff7a8 Mon Sep 17 00:00:00 2001 From: cam Date: Fri, 9 Jul 2021 12:28:04 -0400 Subject: [PATCH 20/33] Added getters, setters, and constructers to Wage.java --- src/Wage.java | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Wage.java b/src/Wage.java index 239b789..2d2779a 100644 --- a/src/Wage.java +++ b/src/Wage.java @@ -4,5 +4,41 @@ public class Wage { double amount; String month; - //should add contructor(s) + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public double getAmount() { + return amount; + } + + public void setAmount(double amount) { + this.amount = amount; + } + + public String getMonth() { + return month; + } + + public void setMonth(String month) { + this.month = month; + } + + public Wage(String source, double amount, String month) { + super(); + this.source = source; + this.amount = amount; + this.month = month; + } + + public Wage() { + super(); + // TODO Auto-generated constructor stub + } + + } From 92b99d6e739c5ece4f6bfab55f2fc773e39c2fd9 Mon Sep 17 00:00:00 2001 From: Joe Castro Date: Mon, 12 Jul 2021 12:59:40 -0400 Subject: [PATCH 21/33] Added updateSavings based on incoming wage and outgoing expenses and whencanibuy --- src/Expense.java | 6 +++--- src/ExpenseCalculator.java | 24 +++++++++++++++++++++--- src/User.java | 8 ++++---- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/Expense.java b/src/Expense.java index 4f9ab07..4a7149a 100644 --- a/src/Expense.java +++ b/src/Expense.java @@ -15,9 +15,9 @@ public class Expense { boolean foundLowerCase = false; boolean foundSymbol = false; boolean foundLength = false; - boolean foundMonthly = false; - boolean foundYearly = false; - boolean foundBiweekly = false; + public boolean foundMonthly = false; + public boolean foundYearly = false; + public boolean foundBiweekly = false; diff --git a/src/ExpenseCalculator.java b/src/ExpenseCalculator.java index 30e5af2..fb9cd6f 100644 --- a/src/ExpenseCalculator.java +++ b/src/ExpenseCalculator.java @@ -93,14 +93,32 @@ public boolean loadIncomeFile(String filePath) { @Override public int whenCanIBuy(String itemname, double price) { - // TODO Auto-generated method stub - return 0; + updateMonthlySavings(); + int numberOfMonths = (int) (price / userAtHand.getSavings());; + return numberOfMonths; } @Override public void updateMonthlySavings() { - // TODO Auto-generated method stub + double totalMonthlyExpenses = 0; + for(Expense i : userAtHand.Spending) { + if (i.foundMonthly) { + totalMonthlyExpenses += i.getAmount(); + } + if (i.foundBiweekly) { + totalMonthlyExpenses += i.getAmount() * 2; + } + } + double totalMonthlyIncome = 0; + double totalIncome = 0; + + for(Wage i : userAtHand.Income) { + totalIncome += i.amount; + } + totalMonthlyIncome = totalIncome / 12; + double finalSavings = totalMonthlyIncome - totalMonthlyExpenses; + userAtHand.setSavings(finalSavings); } diff --git a/src/User.java b/src/User.java index 89b0253..f5b4a6f 100644 --- a/src/User.java +++ b/src/User.java @@ -19,7 +19,7 @@ public class User { Currency CA_Dollars = new Currency(CanadianDollar_rate, "Canadian Dollars"); - private ArrayList Income = new ArrayList(); // user income sources that user can record or view or search by type or month + public ArrayList Income = new ArrayList(); // user income sources that user can record or view or search by type or month public ArrayList Spending = new ArrayList(); //user's expenses private double updatedsavings; @@ -45,9 +45,9 @@ public User() { public void setSavings(double updatedsavings) { this.updatedsavings = monthlysavings; } - //public void getSavings() { - //return Income - Spending; - //} + public double getSavings() { + return updatedsavings; + } public void printExpenses() { System.out.println(this.monthlysavings + " saved this month!"); From 7dafe8707cae298c2b041c9f62fe6cdbf4e74ac8 Mon Sep 17 00:00:00 2001 From: jcreate93 <84466621+jcreate93@users.noreply.github.com> Date: Tue, 13 Jul 2021 10:45:34 -0400 Subject: [PATCH 22/33] Create LoginFrame.java --- src/LoginFrame.java | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/LoginFrame.java diff --git a/src/LoginFrame.java b/src/LoginFrame.java new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/LoginFrame.java @@ -0,0 +1 @@ + From 59b391f3572441dc2e7b0a9b12e6433a43b78da9 Mon Sep 17 00:00:00 2001 From: jcreate93 <84466621+jcreate93@users.noreply.github.com> Date: Tue, 13 Jul 2021 10:58:13 -0400 Subject: [PATCH 23/33] Create Validator.java --- src/Validator.java | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/Validator.java diff --git a/src/Validator.java b/src/Validator.java new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/Validator.java @@ -0,0 +1 @@ + From fc84ec10c1c5decdcc546694c3b8fb7a1df0f257 Mon Sep 17 00:00:00 2001 From: jcreate93 <84466621+jcreate93@users.noreply.github.com> Date: Tue, 13 Jul 2021 11:33:56 -0400 Subject: [PATCH 24/33] Delete Validator.java --- src/Validator.java | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/Validator.java diff --git a/src/Validator.java b/src/Validator.java deleted file mode 100644 index 8b13789..0000000 --- a/src/Validator.java +++ /dev/null @@ -1 +0,0 @@ - From a76bf672797b3e4df90daf096c639a128e2f48ff Mon Sep 17 00:00:00 2001 From: jcreate93 <84466621+jcreate93@users.noreply.github.com> Date: Tue, 13 Jul 2021 11:42:33 -0400 Subject: [PATCH 25/33] Create MenuFrame.java --- src/MenuFrame.java | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/MenuFrame.java diff --git a/src/MenuFrame.java b/src/MenuFrame.java new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/MenuFrame.java @@ -0,0 +1 @@ + From 6ffba2ee9e5825bab6bc58068e9d81e9beaf005f Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Tue, 13 Jul 2021 12:01:33 -0400 Subject: [PATCH 26/33] Added FileInputStream to LoginFrame, initialized Jframe in MenuFrame, updated EWalletApp to reflect changes --- src/EWalletApp.java | 8 +- src/LoginFrame.java | 205 ++++++++++++++++++++++++++++++++++ src/MenuFrame.java | 19 ++++ src/MyFrame.java | 264 +++++++++++++++++++++++--------------------- 4 files changed, 367 insertions(+), 129 deletions(-) diff --git a/src/EWalletApp.java b/src/EWalletApp.java index db9e947..23cfb48 100644 --- a/src/EWalletApp.java +++ b/src/EWalletApp.java @@ -24,11 +24,11 @@ public void CreateUser(String username, String password) {} public static void main(String[] args) { + System.out.println("Login"); + LoginFrame lFrame = new LoginFrame(); + + - MyFrame mainFrame = new MyFrame(); - - //user enters name - System.out.println("What is your name?"); String name = ""; Scanner scnr = new Scanner(System.in); diff --git a/src/LoginFrame.java b/src/LoginFrame.java index 8b13789..b55c2e1 100644 --- a/src/LoginFrame.java +++ b/src/LoginFrame.java @@ -1 +1,206 @@ +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.NumberFormat; +import java.util.Scanner; + +import javax.swing.JButton; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JTextField; +import javax.swing.JLabel; +import javax.swing.JOptionPane; + +import java.awt.Insets; +import java.awt.GridLayout; +import java.awt.BorderLayout; +import javax.swing.BoxLayout; +import javax.swing.JRadioButton; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.LayoutStyle.ComponentPlacement; + +import javax.swing.JFrame; + +public class LoginFrame extends JFrame implements ActionListener { + + + + // initialize variables + private String userName; + private String password; + private JTextField userNameField; + private JTextField passwordField; + + //boolean variables + boolean foundDigit = false; + boolean foundUpperCase = false; + boolean foundLowerCase = false; + boolean foundSymbol = false; + boolean foundLength = false; + + // getters + public String getUserName() { + return userName; + } + public String getPassword() { + return password; + } + public JTextField getUserNameField() { + return userNameField; + } + public JTextField getPasswordField() { + return passwordField; + } + + // setters + public void setUserName(String userName) { + this.userName = userName; + } + public void setPassword(String password) { + this.password = password; + } + public void setUserNameField(JTextField userNameField) { + this.userNameField = userNameField; + + } + public void setPasswordField(JTextField passwordField) { + this.passwordField = passwordField; + } + + LoginFrame(){ + + + + //initialize GUI components + JButton nextButton; + + + //create JFrame window + setTitle("Bank app"); + this.setSize(420, 360); + + // mainPanel + JPanel mainPanel = new JPanel(); + GridBagLayout gbl_mainPanel = new GridBagLayout(); + gbl_mainPanel.columnWidths = new int[] { 93, 50, 104, 56, 0 }; + gbl_mainPanel.rowHeights = new int[] { 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + gbl_mainPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; + gbl_mainPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + Double.MIN_VALUE }; + mainPanel.setLayout(gbl_mainPanel); + getContentPane().add(mainPanel); + + // welcomeLabel + JLabel welcomeLabel = new JLabel("Welcome to Bank App!"); + welcomeLabel.setHorizontalAlignment(SwingConstants.TRAILING); + GridBagConstraints gbc_welcomeLabel = new GridBagConstraints(); + gbc_welcomeLabel.gridwidth = 2; + gbc_welcomeLabel.insets = new Insets(0, 0, 5, 5); + gbc_welcomeLabel.gridx = 1; + gbc_welcomeLabel.gridy = 1; + mainPanel.add(welcomeLabel, gbc_welcomeLabel); + + // userNameLabel + JLabel userNameLabel = new JLabel("Username:"); + GridBagConstraints gbc_userNameLabel = new GridBagConstraints(); + gbc_userNameLabel.anchor = GridBagConstraints.EAST; + gbc_userNameLabel.insets = new Insets(0, 0, 5, 5); + gbc_userNameLabel.gridx = 1; + gbc_userNameLabel.gridy = 3; + mainPanel.add(userNameLabel, gbc_userNameLabel); + + // userNameField + userNameField = new JTextField(); + GridBagConstraints gbc_userNameField = new GridBagConstraints(); + gbc_userNameField.insets = new Insets(0, 0, 5, 5); + gbc_userNameField.fill = GridBagConstraints.HORIZONTAL; + gbc_userNameField.gridx = 2; + gbc_userNameField.gridy = 3; + mainPanel.add(userNameField, gbc_userNameField); + userNameField.setColumns(10); + userName = userNameField.getText(); + + // passwordLabel + JLabel passwordLabel = new JLabel("Password:"); + GridBagConstraints gbc_passwordLabel = new GridBagConstraints(); + gbc_passwordLabel.anchor = GridBagConstraints.EAST; + gbc_passwordLabel.insets = new Insets(0, 0, 5, 5); + gbc_passwordLabel.gridx = 1; + gbc_passwordLabel.gridy = 4; + mainPanel.add(passwordLabel, gbc_passwordLabel); + + // passwordField + passwordField = new JTextField(); + GridBagConstraints gbc_passwordField = new GridBagConstraints(); + gbc_passwordField.insets = new Insets(0, 0, 5, 5); + gbc_passwordField.fill = GridBagConstraints.HORIZONTAL; + gbc_passwordField.gridx = 2; + gbc_passwordField.gridy = 4; + mainPanel.add(passwordField, gbc_passwordField); + passwordField.setColumns(10); + password = passwordField.getText(); + + // next button + nextButton = new JButton("Next"); + nextButton.setFocusable(false); + nextButton.addActionListener(this); + GridBagConstraints gbc_nextButton = new GridBagConstraints(); + gbc_nextButton.insets = new Insets(0, 0, 5, 5); + gbc_nextButton.gridx = 2; + gbc_nextButton.gridy = 6; + mainPanel.add(nextButton, gbc_nextButton); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setVisible(true); + + + +} + + public boolean Validate(String userName, String password) throws IOException { + + //open file and starts verifying username and password against the text file + System.out.println("Opening file... "); //Opening file confidentialInfo.txt. + FileInputStream fileByteStream = new FileInputStream("checkLogin.txt"); //created a new fileInputStream + Scanner inFS = new Scanner(fileByteStream); + + + System.out.println("Verifying your username and password."); + while (inFS.hasNext()) { + + String verifyUsername = inFS.next(); + String verifyPassword = inFS.next(); + if (userName.equals(verifyUsername) && password.equals(verifyPassword)){ + //create object of the second frame and hide this frame + + return true; + } + else { + JOptionPane.showMessageDialog(this,"Username or password not found!"); + } + } + System.out.println("Username not found"); + //close checkLogin.txt file + System.out.println("Closing program..."); + fileByteStream.close(); + return false; + } + + @Override + public void actionPerformed(ActionEvent arg0) { + MenuFrame mFrame = MenuFrame(); + userName = userNameField.getText(); + System.out.println(userName); + + password = passwordField.getText(); + System.out.println(password); + } + +} diff --git a/src/MenuFrame.java b/src/MenuFrame.java index 8b13789..34d4c67 100644 --- a/src/MenuFrame.java +++ b/src/MenuFrame.java @@ -1 +1,20 @@ +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +public class MenuFrame extends LoginFrame{ + +MenuFrame(){ + + //initialize GUI components + JButton nextButton; + + + //create JFrame window + setTitle("Bank app"); + this.setSize(420, 360); + + // mainPanel + JPanel mainPanel = new JPanel(); +} +} diff --git a/src/MyFrame.java b/src/MyFrame.java index f1f78ab..135943e 100644 --- a/src/MyFrame.java +++ b/src/MyFrame.java @@ -17,139 +17,153 @@ import javax.swing.JRadioButton; import javax.swing.JPanel; import javax.swing.SwingConstants; -import javax.swing.GroupLayout; -import javax.swing.GroupLayout.Alignment; import javax.swing.LayoutStyle.ComponentPlacement; -public class MyFrame extends JFrame implements ActionListener{ - //initialize variables - private String firstName; - private String userName; - private String password; - private JTextField firstNameField; - private JTextField userNameField; - private JTextField passwordField; - - -MyFrame(){ - - - //initialize GUI components - JLabel firstNameLabel; - JButton nextButton; - - - //create JFrame window - setTitle("Bank app"); - this.setSize(420, 360); - - //mainPanel - JPanel mainPanel = new JPanel(); - GridBagLayout gbl_mainPanel = new GridBagLayout(); - gbl_mainPanel.columnWidths = new int[]{93, 50, 104, 56, 0}; - gbl_mainPanel.rowHeights = new int[]{19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - gbl_mainPanel.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE}; - gbl_mainPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; - mainPanel.setLayout(gbl_mainPanel); - getContentPane().add(mainPanel); - - //welcomeLabel - JLabel welcomeLabel = new JLabel("Welcome to Bank App!"); - welcomeLabel.setHorizontalAlignment(SwingConstants.TRAILING); - GridBagConstraints gbc_welcomeLabel = new GridBagConstraints(); - gbc_welcomeLabel.gridwidth = 2; - gbc_welcomeLabel.insets = new Insets(0, 0, 5, 5); - gbc_welcomeLabel.gridx = 1; - gbc_welcomeLabel.gridy = 1; - mainPanel.add(welcomeLabel, gbc_welcomeLabel); - - - //firstNameLabel - firstNameLabel = new JLabel("Enter your first name: "); - GridBagConstraints gbc_firstNameLabel = new GridBagConstraints(); - gbc_firstNameLabel.anchor = GridBagConstraints.WEST; - gbc_firstNameLabel.insets = new Insets(0, 0, 5, 5); - gbc_firstNameLabel.gridx = 1; - gbc_firstNameLabel.gridy = 3; - mainPanel.add(firstNameLabel, gbc_firstNameLabel); - - - //firstNameField - firstNameField = new JTextField(); - GridBagConstraints gbc_firstNameField = new GridBagConstraints(); - gbc_firstNameField.insets = new Insets(0, 0, 5, 5); - gbc_firstNameField.fill = GridBagConstraints.HORIZONTAL; - gbc_firstNameField.gridx = 2; - gbc_firstNameField.gridy = 3; - mainPanel.add(firstNameField, gbc_firstNameField); - firstNameField.setColumns(10); - - //userNameLabel - JLabel userNameLabel = new JLabel("Username:"); - GridBagConstraints gbc_userNameLabel = new GridBagConstraints(); - gbc_userNameLabel.anchor = GridBagConstraints.EAST; - gbc_userNameLabel.insets = new Insets(0, 0, 5, 5); - gbc_userNameLabel.gridx = 1; - gbc_userNameLabel.gridy = 4; - mainPanel.add(userNameLabel, gbc_userNameLabel); - - //userNameField - userNameField = new JTextField(); - GridBagConstraints gbc_userNameField = new GridBagConstraints(); - gbc_userNameField.insets = new Insets(0, 0, 5, 5); - gbc_userNameField.fill = GridBagConstraints.HORIZONTAL; - gbc_userNameField.gridx = 2; - gbc_userNameField.gridy = 4; - mainPanel.add(userNameField, gbc_userNameField); - userNameField.setColumns(10); - - //passwordLabel - JLabel passwordLabel = new JLabel("Password:"); - GridBagConstraints gbc_passwordLabel = new GridBagConstraints(); - gbc_passwordLabel.anchor = GridBagConstraints.EAST; - gbc_passwordLabel.insets = new Insets(0, 0, 5, 5); - gbc_passwordLabel.gridx = 1; - gbc_passwordLabel.gridy = 5; - mainPanel.add(passwordLabel, gbc_passwordLabel); - - //passwordField - passwordField = new JTextField(); - GridBagConstraints gbc_passwordField = new GridBagConstraints(); - gbc_passwordField.insets = new Insets(0, 0, 5, 5); - gbc_passwordField.fill = GridBagConstraints.HORIZONTAL; - gbc_passwordField.gridx = 2; - gbc_passwordField.gridy = 5; - mainPanel.add(passwordField, gbc_passwordField); - passwordField.setColumns(10); - - //next button - nextButton = new JButton("Next"); - nextButton.setFocusable(false); - nextButton.addActionListener(this); - GridBagConstraints gbc_nextButton = new GridBagConstraints(); - gbc_nextButton.insets = new Insets(0, 0, 5, 5); - gbc_nextButton.gridx = 2; - gbc_nextButton.gridy = 7; - mainPanel.add(nextButton, gbc_nextButton); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.setVisible(true); - +public class MyFrame extends JFrame implements ActionListener { + + // initialize variables + private String firstName; + private String userName; + private String password; + private JTextField firstNameField; + private JTextField userNameField; + private JTextField passwordField; + + // getters + public String getUserName() { + return userName; + } + public String getPassword() { + return password; + } + public JTextField getUserNameField() { + return userNameField; + } + public JTextField getPasswordField() { + return passwordField; + } + + // setters + public void setUserName(String userName) { + this.userName = userName; + } + public void setPassword(String password) { + this.password = password; + } + public void setUserNameField(JTextField userNameField) { + this.userNameField = userNameField; } - + public void setPasswordField(JTextField passwordField) { + this.passwordField = passwordField; + } + + MyFrame() { + + // initialize GUI components + JButton nextButton; + + // create JFrame window + setTitle("Bank app"); + this.setSize(420, 360); + + // mainPanel + JPanel mainPanel = new JPanel(); + GridBagLayout gbl_mainPanel = new GridBagLayout(); + gbl_mainPanel.columnWidths = new int[] { 93, 50, 104, 56, 0 }; + gbl_mainPanel.rowHeights = new int[] { 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + gbl_mainPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; + gbl_mainPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + Double.MIN_VALUE }; + mainPanel.setLayout(gbl_mainPanel); + getContentPane().add(mainPanel); + + // welcomeLabel + JLabel welcomeLabel = new JLabel("Welcome to Bank App!"); + welcomeLabel.setHorizontalAlignment(SwingConstants.TRAILING); + GridBagConstraints gbc_welcomeLabel = new GridBagConstraints(); + gbc_welcomeLabel.gridwidth = 2; + gbc_welcomeLabel.insets = new Insets(0, 0, 5, 5); + gbc_welcomeLabel.gridx = 1; + gbc_welcomeLabel.gridy = 1; + mainPanel.add(welcomeLabel, gbc_welcomeLabel); + + // userNameLabel + JLabel userNameLabel = new JLabel("Username:"); + GridBagConstraints gbc_userNameLabel = new GridBagConstraints(); + gbc_userNameLabel.anchor = GridBagConstraints.EAST; + gbc_userNameLabel.insets = new Insets(0, 0, 5, 5); + gbc_userNameLabel.gridx = 1; + gbc_userNameLabel.gridy = 3; + mainPanel.add(userNameLabel, gbc_userNameLabel); + + // userNameField + userNameField = new JTextField(); + GridBagConstraints gbc_userNameField = new GridBagConstraints(); + gbc_userNameField.insets = new Insets(0, 0, 5, 5); + gbc_userNameField.fill = GridBagConstraints.HORIZONTAL; + gbc_userNameField.gridx = 2; + gbc_userNameField.gridy = 3; + mainPanel.add(userNameField, gbc_userNameField); + userNameField.setColumns(10); + userName = userNameField.getText(); + + // passwordLabel + JLabel passwordLabel = new JLabel("Password:"); + GridBagConstraints gbc_passwordLabel = new GridBagConstraints(); + gbc_passwordLabel.anchor = GridBagConstraints.EAST; + gbc_passwordLabel.insets = new Insets(0, 0, 5, 5); + gbc_passwordLabel.gridx = 1; + gbc_passwordLabel.gridy = 4; + mainPanel.add(passwordLabel, gbc_passwordLabel); + + // passwordField + passwordField = new JTextField(); + GridBagConstraints gbc_passwordField = new GridBagConstraints(); + gbc_passwordField.insets = new Insets(0, 0, 5, 5); + gbc_passwordField.fill = GridBagConstraints.HORIZONTAL; + gbc_passwordField.gridx = 2; + gbc_passwordField.gridy = 4; + mainPanel.add(passwordField, gbc_passwordField); + passwordField.setColumns(10); + password = passwordField.getText(); + + // next button + nextButton = new JButton("Next"); + nextButton.setFocusable(false); + nextButton.addActionListener(this); + GridBagConstraints gbc_nextButton = new GridBagConstraints(); + gbc_nextButton.insets = new Insets(0, 0, 5, 5); + gbc_nextButton.gridx = 2; + gbc_nextButton.gridy = 6; + mainPanel.add(nextButton, gbc_nextButton); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setVisible(true); + + } + + public boolean Validate(String userName, String password) { + + return true; + /* + * if (userName.equals(verifiedUsername) && + * password.equals(verifiedPassword)){//create object of the second frame and + * hide this frame } else { //message box JOptionPane.showMessageDialog(this, + * "Enter a positive distance value!"); } + */ + } + +//create new frame for seperate functionality @Override public void actionPerformed(ActionEvent event) { - - firstName = firstNameField.getText(); - System.out.println(firstName); - + userName = userNameField.getText(); System.out.println(userName); - + password = passwordField.getText(); System.out.println(password); - - - + + // call validate method + } - + } From 10ee06e159cd6e2540b985d8ead3ccc185708b58 Mon Sep 17 00:00:00 2001 From: MohamedAbusharkh Date: Tue, 13 Jul 2021 14:37:51 -0400 Subject: [PATCH 27/33] modified login file reading, login code sequence --- src/checkLogin.txt => checkLogin.txt | 4 +- src/LoginFrame.java | 57 +++++++++++++++++----------- src/MenuFrame.java | 4 +- 3 files changed, 39 insertions(+), 26 deletions(-) rename src/checkLogin.txt => checkLogin.txt (66%) diff --git a/src/checkLogin.txt b/checkLogin.txt similarity index 66% rename from src/checkLogin.txt rename to checkLogin.txt index 38ba80d..94346de 100644 --- a/src/checkLogin.txt +++ b/checkLogin.txt @@ -1,5 +1,5 @@ -User1111 -Password1111 +User1 +Password1 User2222 Password2222 User3333 diff --git a/src/LoginFrame.java b/src/LoginFrame.java index b55c2e1..d74f685 100644 --- a/src/LoginFrame.java +++ b/src/LoginFrame.java @@ -74,14 +74,10 @@ public void setPasswordField(JTextField passwordField) { this.passwordField = passwordField; } - LoginFrame(){ - - - + LoginFrame(){ //initialize GUI components JButton nextButton; - - + //create JFrame window setTitle("Bank app"); this.setSize(420, 360); @@ -125,7 +121,6 @@ public void setPasswordField(JTextField passwordField) { gbc_userNameField.gridy = 3; mainPanel.add(userNameField, gbc_userNameField); userNameField.setColumns(10); - userName = userNameField.getText(); // passwordLabel JLabel passwordLabel = new JLabel("Password:"); @@ -163,7 +158,7 @@ public void setPasswordField(JTextField passwordField) { } - public boolean Validate(String userName, String password) throws IOException { + public boolean Validate() throws IOException { //open file and starts verifying username and password against the text file System.out.println("Opening file... "); //Opening file confidentialInfo.txt. @@ -173,34 +168,52 @@ public boolean Validate(String userName, String password) throws IOException { System.out.println("Verifying your username and password."); while (inFS.hasNext()) { - String verifyUsername = inFS.next(); String verifyPassword = inFS.next(); if (userName.equals(verifyUsername) && password.equals(verifyPassword)){ - //create object of the second frame and hide this frame + JOptionPane.showMessageDialog(this,"login success!"); return true; } - else { - JOptionPane.showMessageDialog(this,"Username or password not found!"); - } - } - System.out.println("Username not found"); - //close checkLogin.txt file - System.out.println("Closing program..."); - fileByteStream.close(); - return false; + + } + //only when we are out of the loop, we are sure un/pwd not found + JOptionPane.showMessageDialog(this,"Username or password not found!"); + System.out.println("Username not found"); + //close checkLogin.txt file + System.out.println("Closing program..."); + fileByteStream.close(); + return false; } @Override public void actionPerformed(ActionEvent arg0) { - MenuFrame mFrame = MenuFrame(); + userName = userNameField.getText(); System.out.println(userName); - + password = passwordField.getText(); System.out.println(password); - } + try { + if (Validate()) { + + // + //TODOs login success message box + // run the menuframe + //create object of the second frame and hide this frame + new MenuFrame(); + //equivalent to --> MenuFrame mFrame = new MenuFrame(); + } + else { + //TODO login failure message box + System.out.println(" failed login try again"); + } + } catch (IOException e) { + System.out.println(" login file exception"); + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } diff --git a/src/MenuFrame.java b/src/MenuFrame.java index 34d4c67..d4985e4 100644 --- a/src/MenuFrame.java +++ b/src/MenuFrame.java @@ -2,7 +2,7 @@ import javax.swing.JFrame; import javax.swing.JPanel; -public class MenuFrame extends LoginFrame{ +public class MenuFrame extends JFrame{ MenuFrame(){ @@ -11,7 +11,7 @@ public class MenuFrame extends LoginFrame{ //create JFrame window - setTitle("Bank app"); + setTitle("Bank app--Main Menu "); this.setSize(420, 360); // mainPanel From 36330df4a64e858d4a6103d326d6ee0ed65e3135 Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Tue, 13 Jul 2021 21:35:48 -0400 Subject: [PATCH 28/33] update EWalletApp, LoginFrame, MenuFrame --- src/EWalletApp.java | 2 +- src/LoginFrame.java | 250 ++++++++++++++++++++++---------------------- src/MenuFrame.java | 111 +++++++++++++++++--- 3 files changed, 224 insertions(+), 139 deletions(-) diff --git a/src/EWalletApp.java b/src/EWalletApp.java index 23cfb48..d5ae999 100644 --- a/src/EWalletApp.java +++ b/src/EWalletApp.java @@ -26,7 +26,7 @@ public void CreateUser(String username, String password) {} public static void main(String[] args) { System.out.println("Login"); LoginFrame lFrame = new LoginFrame(); - + MenuFrame mFrame = new MenuFrame(); String name = ""; diff --git a/src/LoginFrame.java b/src/LoginFrame.java index b55c2e1..d92eb07 100644 --- a/src/LoginFrame.java +++ b/src/LoginFrame.java @@ -29,16 +29,17 @@ import javax.swing.JFrame; public class LoginFrame extends JFrame implements ActionListener { + + // initialize GUI components + JButton nextButton; - - // initialize variables private String userName; private String password; private JTextField userNameField; private JTextField passwordField; - - //boolean variables + + // boolean variables boolean foundDigit = false; boolean foundUpperCase = false; boolean foundLowerCase = false; @@ -49,12 +50,15 @@ public class LoginFrame extends JFrame implements ActionListener { public String getUserName() { return userName; } + public String getPassword() { return password; } + public JTextField getUserNameField() { return userNameField; } + public JTextField getPasswordField() { return passwordField; } @@ -63,144 +67,140 @@ public JTextField getPasswordField() { public void setUserName(String userName) { this.userName = userName; } + public void setPassword(String password) { this.password = password; } + public void setUserNameField(JTextField userNameField) { this.userNameField = userNameField; - + } + public void setPasswordField(JTextField passwordField) { this.passwordField = passwordField; } - LoginFrame(){ - - - - //initialize GUI components - JButton nextButton; - - - //create JFrame window - setTitle("Bank app"); - this.setSize(420, 360); - - // mainPanel - JPanel mainPanel = new JPanel(); - GridBagLayout gbl_mainPanel = new GridBagLayout(); - gbl_mainPanel.columnWidths = new int[] { 93, 50, 104, 56, 0 }; - gbl_mainPanel.rowHeights = new int[] { 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - gbl_mainPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; - gbl_mainPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - Double.MIN_VALUE }; - mainPanel.setLayout(gbl_mainPanel); - getContentPane().add(mainPanel); - - // welcomeLabel - JLabel welcomeLabel = new JLabel("Welcome to Bank App!"); - welcomeLabel.setHorizontalAlignment(SwingConstants.TRAILING); - GridBagConstraints gbc_welcomeLabel = new GridBagConstraints(); - gbc_welcomeLabel.gridwidth = 2; - gbc_welcomeLabel.insets = new Insets(0, 0, 5, 5); - gbc_welcomeLabel.gridx = 1; - gbc_welcomeLabel.gridy = 1; - mainPanel.add(welcomeLabel, gbc_welcomeLabel); - - // userNameLabel - JLabel userNameLabel = new JLabel("Username:"); - GridBagConstraints gbc_userNameLabel = new GridBagConstraints(); - gbc_userNameLabel.anchor = GridBagConstraints.EAST; - gbc_userNameLabel.insets = new Insets(0, 0, 5, 5); - gbc_userNameLabel.gridx = 1; - gbc_userNameLabel.gridy = 3; - mainPanel.add(userNameLabel, gbc_userNameLabel); - - // userNameField - userNameField = new JTextField(); - GridBagConstraints gbc_userNameField = new GridBagConstraints(); - gbc_userNameField.insets = new Insets(0, 0, 5, 5); - gbc_userNameField.fill = GridBagConstraints.HORIZONTAL; - gbc_userNameField.gridx = 2; - gbc_userNameField.gridy = 3; - mainPanel.add(userNameField, gbc_userNameField); - userNameField.setColumns(10); - userName = userNameField.getText(); - - // passwordLabel - JLabel passwordLabel = new JLabel("Password:"); - GridBagConstraints gbc_passwordLabel = new GridBagConstraints(); - gbc_passwordLabel.anchor = GridBagConstraints.EAST; - gbc_passwordLabel.insets = new Insets(0, 0, 5, 5); - gbc_passwordLabel.gridx = 1; - gbc_passwordLabel.gridy = 4; - mainPanel.add(passwordLabel, gbc_passwordLabel); - - // passwordField - passwordField = new JTextField(); - GridBagConstraints gbc_passwordField = new GridBagConstraints(); - gbc_passwordField.insets = new Insets(0, 0, 5, 5); - gbc_passwordField.fill = GridBagConstraints.HORIZONTAL; - gbc_passwordField.gridx = 2; - gbc_passwordField.gridy = 4; - mainPanel.add(passwordField, gbc_passwordField); - passwordField.setColumns(10); - password = passwordField.getText(); + LoginFrame() { + + + // create JFrame window + setTitle("Bank app"); + this.setSize(420, 360); + + // mainPanel + JPanel mainPanel = new JPanel(); + GridBagLayout gbl_mainPanel = new GridBagLayout(); + gbl_mainPanel.columnWidths = new int[] { 93, 50, 104, 56, 0 }; + gbl_mainPanel.rowHeights = new int[] { 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + gbl_mainPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; + gbl_mainPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + Double.MIN_VALUE }; + mainPanel.setLayout(gbl_mainPanel); + getContentPane().add(mainPanel); + + // welcomeLabel + JLabel welcomeLabel = new JLabel("Welcome to Bank App!"); + welcomeLabel.setHorizontalAlignment(SwingConstants.TRAILING); + GridBagConstraints gbc_welcomeLabel = new GridBagConstraints(); + gbc_welcomeLabel.gridwidth = 2; + gbc_welcomeLabel.insets = new Insets(0, 0, 5, 5); + gbc_welcomeLabel.gridx = 1; + gbc_welcomeLabel.gridy = 1; + mainPanel.add(welcomeLabel, gbc_welcomeLabel); + + // userNameLabel + JLabel userNameLabel = new JLabel("Username:"); + GridBagConstraints gbc_userNameLabel = new GridBagConstraints(); + gbc_userNameLabel.anchor = GridBagConstraints.EAST; + gbc_userNameLabel.insets = new Insets(0, 0, 5, 5); + gbc_userNameLabel.gridx = 1; + gbc_userNameLabel.gridy = 3; + mainPanel.add(userNameLabel, gbc_userNameLabel); + + // userNameField + userNameField = new JTextField(); + GridBagConstraints gbc_userNameField = new GridBagConstraints(); + gbc_userNameField.insets = new Insets(0, 0, 5, 5); + gbc_userNameField.fill = GridBagConstraints.HORIZONTAL; + gbc_userNameField.gridx = 2; + gbc_userNameField.gridy = 3; + mainPanel.add(userNameField, gbc_userNameField); + userNameField.setColumns(10); + userName = userNameField.getText(); - // next button - nextButton = new JButton("Next"); - nextButton.setFocusable(false); - nextButton.addActionListener(this); - GridBagConstraints gbc_nextButton = new GridBagConstraints(); - gbc_nextButton.insets = new Insets(0, 0, 5, 5); - gbc_nextButton.gridx = 2; - gbc_nextButton.gridy = 6; - mainPanel.add(nextButton, gbc_nextButton); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.setVisible(true); + // passwordLabel + JLabel passwordLabel = new JLabel("Password:"); + GridBagConstraints gbc_passwordLabel = new GridBagConstraints(); + gbc_passwordLabel.anchor = GridBagConstraints.EAST; + gbc_passwordLabel.insets = new Insets(0, 0, 5, 5); + gbc_passwordLabel.gridx = 1; + gbc_passwordLabel.gridy = 4; + mainPanel.add(passwordLabel, gbc_passwordLabel); + + // passwordField + passwordField = new JTextField(); + GridBagConstraints gbc_passwordField = new GridBagConstraints(); + gbc_passwordField.insets = new Insets(0, 0, 5, 5); + gbc_passwordField.fill = GridBagConstraints.HORIZONTAL; + gbc_passwordField.gridx = 2; + gbc_passwordField.gridy = 4; + mainPanel.add(passwordField, gbc_passwordField); + passwordField.setColumns(10); + password = passwordField.getText(); - + // next button + nextButton = new JButton("Next"); + nextButton.setFocusable(false); + nextButton.addActionListener(this); + GridBagConstraints gbc_nextButton = new GridBagConstraints(); + gbc_nextButton.insets = new Insets(0, 0, 5, 5); + gbc_nextButton.gridx = 2; + gbc_nextButton.gridy = 6; + mainPanel.add(nextButton, gbc_nextButton); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setVisible(true); -} + } - public boolean Validate(String userName, String password) throws IOException { - - //open file and starts verifying username and password against the text file - System.out.println("Opening file... "); //Opening file confidentialInfo.txt. - FileInputStream fileByteStream = new FileInputStream("checkLogin.txt"); //created a new fileInputStream - Scanner inFS = new Scanner(fileByteStream); - - - System.out.println("Verifying your username and password."); - while (inFS.hasNext()) { - - String verifyUsername = inFS.next(); - String verifyPassword = inFS.next(); - if (userName.equals(verifyUsername) && password.equals(verifyPassword)){ - //create object of the second frame and hide this frame - - return true; - } - else { - JOptionPane.showMessageDialog(this,"Username or password not found!"); - } + public boolean Validate(String userName, String password) throws IOException { + + // open file and starts verifying username and password against the text file + System.out.println("Opening file... "); // Opening file confidentialInfo.txt. + FileInputStream fileByteStream = new FileInputStream("checkLogin.txt"); // created a new fileInputStream + Scanner inFS = new Scanner(fileByteStream); + + System.out.println("Verifying your username and password."); + while (inFS.hasNext()) { + + String verifyUsername = inFS.next(); + String verifyPassword = inFS.next(); + if (userName.equals(verifyUsername) && password.equals(verifyPassword)) { + // create object of the second frame and hide this frame + + return true; + } else { + JOptionPane.showMessageDialog(this, "Username or password not found!"); + } + } + System.out.println("Username not found"); + // close checkLogin.txt file + System.out.println("Closing program..."); + fileByteStream.close(); + return false; } - System.out.println("Username not found"); - //close checkLogin.txt file - System.out.println("Closing program..."); - fileByteStream.close(); - return false; - } - + @Override - public void actionPerformed(ActionEvent arg0) { - MenuFrame mFrame = MenuFrame(); - userName = userNameField.getText(); - System.out.println(userName); + public void actionPerformed(ActionEvent event) { + if(event.getSource() == nextButton) { + MenuFrame mFrame = new MenuFrame(); + userName = userNameField.getText(); + System.out.println(userName); - password = passwordField.getText(); - System.out.println(password); + password = passwordField.getText(); + System.out.println(password); + } + } } - diff --git a/src/MenuFrame.java b/src/MenuFrame.java index 34d4c67..bb8427d 100644 --- a/src/MenuFrame.java +++ b/src/MenuFrame.java @@ -1,20 +1,105 @@ +import java.awt.GridBagLayout; + import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; +import javax.swing.JLabel; +import javax.swing.JOptionPane; -public class MenuFrame extends LoginFrame{ - -MenuFrame(){ - - //initialize GUI components +import java.awt.GridBagConstraints; +import java.awt.Insets; +import java.awt.BorderLayout; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.Color; +import javax.swing.UIManager; + +public class MenuFrame extends JFrame implements ActionListener { + + // initialize GUI components JButton nextButton; + JButton addIncomeButton; + JButton addExpenseButton; + private JButton reportsButton; - - //create JFrame window - setTitle("Bank app"); - this.setSize(420, 360); - - // mainPanel - JPanel mainPanel = new JPanel(); -} + public MenuFrame() { + + + + // create JFrame window + setTitle("Bank app"); + this.setSize(420, 360); + GridBagLayout gridBagLayout = new GridBagLayout(); + gridBagLayout.columnWidths = new int[]{406, 0}; + gridBagLayout.rowHeights = new int[]{23, 0, 0, 0, 0, 0}; + gridBagLayout.columnWeights = new double[]{0.0, Double.MIN_VALUE}; + gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; + getContentPane().setLayout(gridBagLayout); + + //mainPanel + JPanel mainPanel = new JPanel(); + GridBagConstraints gbc_mainPanel = new GridBagConstraints(); + gbc_mainPanel.insets = new Insets(0, 0, 5, 0); + gbc_mainPanel.anchor = GridBagConstraints.NORTH; + gbc_mainPanel.fill = GridBagConstraints.HORIZONTAL; + gbc_mainPanel.gridx = 0; + gbc_mainPanel.gridy = 0; + getContentPane().add(mainPanel, gbc_mainPanel); + + //welcome label + JLabel welcomeLabel = new JLabel("Welcome!"); + mainPanel.add(welcomeLabel); + + //Add income button + addIncomeButton = new JButton("Add income"); + addIncomeButton.setBackground(UIManager.getColor("Button.disabledForeground")); + addIncomeButton.setForeground(UIManager.getColor("CheckBox.foreground")); + addIncomeButton.addActionListener(this); + GridBagConstraints gbc_addIncomeButton = new GridBagConstraints(); + gbc_addIncomeButton.insets = new Insets(0, 0, 5, 0); + gbc_addIncomeButton.gridx = 0; + gbc_addIncomeButton.gridy = 2; + getContentPane().add(addIncomeButton, gbc_addIncomeButton); + + //add expense button + addExpenseButton = new JButton("Add Expense"); + addExpenseButton.setBackground(UIManager.getColor("Button.darkShadow")); + addExpenseButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + } + }); + GridBagConstraints gbc_addExpenseButton = new GridBagConstraints(); + gbc_addExpenseButton.insets = new Insets(0, 0, 5, 0); + gbc_addExpenseButton.gridx = 0; + gbc_addExpenseButton.gridy = 3; + getContentPane().add(addExpenseButton, gbc_addExpenseButton); + + reportsButton = new JButton("Reports"); + reportsButton.setBackground(UIManager.getColor("Button.disabledForeground")); + reportsButton.setForeground(UIManager.getColor("Button.disabledForeground")); + reportsButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + } + }); + GridBagConstraints gbc_reportsButton = new GridBagConstraints(); + gbc_reportsButton.gridx = 0; + gbc_reportsButton.gridy = 4; + getContentPane().add(reportsButton, gbc_reportsButton); + + + + + } + + @Override + public void actionPerformed(ActionEvent event) { + if(event.getSource() == addIncomeButton) { + JFrame incomeFrame = new JFrame(); + String incomeName = JOptionPane.showInputDialog(incomeFrame,"Enter Income"); + } + if(event.getSource() == addExpenseButton) { + JFrame expenseFrame = new JFrame(); + String expenseName = JOptionPane.showInputDialog(expenseFrame,"Enter Expense"); + } + } } From 0109ac4fce7a09ebf251b40cb3268656f0658869 Mon Sep 17 00:00:00 2001 From: jcreate93 <84466621+jcreate93@users.noreply.github.com> Date: Wed, 14 Jul 2021 09:47:44 -0400 Subject: [PATCH 29/33] Delete MyFrame.java copied code from file to LoginFrame --- src/MyFrame.java | 169 ----------------------------------------------- 1 file changed, 169 deletions(-) delete mode 100644 src/MyFrame.java diff --git a/src/MyFrame.java b/src/MyFrame.java deleted file mode 100644 index 135943e..0000000 --- a/src/MyFrame.java +++ /dev/null @@ -1,169 +0,0 @@ -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.text.NumberFormat; -import java.util.Scanner; - -import javax.swing.JButton; -import javax.swing.JFormattedTextField; -import javax.swing.JFrame; -import javax.swing.JTextField; -import javax.swing.JLabel; -import java.awt.Insets; -import java.awt.GridLayout; -import java.awt.BorderLayout; -import javax.swing.BoxLayout; -import javax.swing.JRadioButton; -import javax.swing.JPanel; -import javax.swing.SwingConstants; -import javax.swing.LayoutStyle.ComponentPlacement; - -public class MyFrame extends JFrame implements ActionListener { - - // initialize variables - private String firstName; - private String userName; - private String password; - private JTextField firstNameField; - private JTextField userNameField; - private JTextField passwordField; - - // getters - public String getUserName() { - return userName; - } - public String getPassword() { - return password; - } - public JTextField getUserNameField() { - return userNameField; - } - public JTextField getPasswordField() { - return passwordField; - } - - // setters - public void setUserName(String userName) { - this.userName = userName; - } - public void setPassword(String password) { - this.password = password; - } - public void setUserNameField(JTextField userNameField) { - this.userNameField = userNameField; - } - public void setPasswordField(JTextField passwordField) { - this.passwordField = passwordField; - } - - MyFrame() { - - // initialize GUI components - JButton nextButton; - - // create JFrame window - setTitle("Bank app"); - this.setSize(420, 360); - - // mainPanel - JPanel mainPanel = new JPanel(); - GridBagLayout gbl_mainPanel = new GridBagLayout(); - gbl_mainPanel.columnWidths = new int[] { 93, 50, 104, 56, 0 }; - gbl_mainPanel.rowHeights = new int[] { 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - gbl_mainPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; - gbl_mainPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - Double.MIN_VALUE }; - mainPanel.setLayout(gbl_mainPanel); - getContentPane().add(mainPanel); - - // welcomeLabel - JLabel welcomeLabel = new JLabel("Welcome to Bank App!"); - welcomeLabel.setHorizontalAlignment(SwingConstants.TRAILING); - GridBagConstraints gbc_welcomeLabel = new GridBagConstraints(); - gbc_welcomeLabel.gridwidth = 2; - gbc_welcomeLabel.insets = new Insets(0, 0, 5, 5); - gbc_welcomeLabel.gridx = 1; - gbc_welcomeLabel.gridy = 1; - mainPanel.add(welcomeLabel, gbc_welcomeLabel); - - // userNameLabel - JLabel userNameLabel = new JLabel("Username:"); - GridBagConstraints gbc_userNameLabel = new GridBagConstraints(); - gbc_userNameLabel.anchor = GridBagConstraints.EAST; - gbc_userNameLabel.insets = new Insets(0, 0, 5, 5); - gbc_userNameLabel.gridx = 1; - gbc_userNameLabel.gridy = 3; - mainPanel.add(userNameLabel, gbc_userNameLabel); - - // userNameField - userNameField = new JTextField(); - GridBagConstraints gbc_userNameField = new GridBagConstraints(); - gbc_userNameField.insets = new Insets(0, 0, 5, 5); - gbc_userNameField.fill = GridBagConstraints.HORIZONTAL; - gbc_userNameField.gridx = 2; - gbc_userNameField.gridy = 3; - mainPanel.add(userNameField, gbc_userNameField); - userNameField.setColumns(10); - userName = userNameField.getText(); - - // passwordLabel - JLabel passwordLabel = new JLabel("Password:"); - GridBagConstraints gbc_passwordLabel = new GridBagConstraints(); - gbc_passwordLabel.anchor = GridBagConstraints.EAST; - gbc_passwordLabel.insets = new Insets(0, 0, 5, 5); - gbc_passwordLabel.gridx = 1; - gbc_passwordLabel.gridy = 4; - mainPanel.add(passwordLabel, gbc_passwordLabel); - - // passwordField - passwordField = new JTextField(); - GridBagConstraints gbc_passwordField = new GridBagConstraints(); - gbc_passwordField.insets = new Insets(0, 0, 5, 5); - gbc_passwordField.fill = GridBagConstraints.HORIZONTAL; - gbc_passwordField.gridx = 2; - gbc_passwordField.gridy = 4; - mainPanel.add(passwordField, gbc_passwordField); - passwordField.setColumns(10); - password = passwordField.getText(); - - // next button - nextButton = new JButton("Next"); - nextButton.setFocusable(false); - nextButton.addActionListener(this); - GridBagConstraints gbc_nextButton = new GridBagConstraints(); - gbc_nextButton.insets = new Insets(0, 0, 5, 5); - gbc_nextButton.gridx = 2; - gbc_nextButton.gridy = 6; - mainPanel.add(nextButton, gbc_nextButton); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.setVisible(true); - - } - - public boolean Validate(String userName, String password) { - - return true; - /* - * if (userName.equals(verifiedUsername) && - * password.equals(verifiedPassword)){//create object of the second frame and - * hide this frame } else { //message box JOptionPane.showMessageDialog(this, - * "Enter a positive distance value!"); } - */ - } - -//create new frame for seperate functionality - @Override - public void actionPerformed(ActionEvent event) { - - userName = userNameField.getText(); - System.out.println(userName); - - password = passwordField.getText(); - System.out.println(password); - - // call validate method - - } - -} From 6fc7a80629ad015e22a68c7ce98f5ed12a023eff Mon Sep 17 00:00:00 2001 From: jcreate93 Date: Wed, 21 Jul 2021 10:43:26 -0400 Subject: [PATCH 30/33] latest version --- checkLogin.txt | 4 ++-- src/EWalletApp.java | 2 +- src/LoginFrame.java | 17 ++++++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/checkLogin.txt b/checkLogin.txt index 94346de..38ba80d 100644 --- a/checkLogin.txt +++ b/checkLogin.txt @@ -1,5 +1,5 @@ -User1 -Password1 +User1111 +Password1111 User2222 Password2222 User3333 diff --git a/src/EWalletApp.java b/src/EWalletApp.java index d5ae999..85d05dd 100644 --- a/src/EWalletApp.java +++ b/src/EWalletApp.java @@ -26,7 +26,7 @@ public void CreateUser(String username, String password) {} public static void main(String[] args) { System.out.println("Login"); LoginFrame lFrame = new LoginFrame(); - MenuFrame mFrame = new MenuFrame(); + String name = ""; diff --git a/src/LoginFrame.java b/src/LoginFrame.java index cc20077..eba84ee 100644 --- a/src/LoginFrame.java +++ b/src/LoginFrame.java @@ -242,25 +242,28 @@ public void actionPerformed(ActionEvent event) { System.out.println(password); try { if (Validate()) { - - String sucessLogin = JOptionPane.showInputDialog(sucessLogin,"Success!."); + String sucessLogin = null; + sucessLogin = JOptionPane.showInputDialog(sucessLogin,"Success!."); //TODOs login success message box - + // run the menuframe //create object of the second frame and hide this frame + new MenuFrame(); + this.setVisible(false); + //equivalent to --> MenuFrame mFrame = new MenuFrame(); } else { - String failLogin = JOptionPane.showInputDialog(failLogin,"Failed login. Try again."); + String failLogin = null; + failLogin = JOptionPane.showInputDialog(failLogin,"Failed login. Try again."); System.out.println(" failed login try again"); } } catch (IOException e) { System.out.println(" login file exception"); - // TODO Auto-generated catch block e.printStackTrace(); } - }} -}>>>>>>>10ee 06e159 cd6e2540b985d8ead3ccc185708b58 + } +} From dbbf7f6a72ee3a9d9307909bf63af909a8ae4dc8 Mon Sep 17 00:00:00 2001 From: jcreate93 <84466621+jcreate93@users.noreply.github.com> Date: Wed, 21 Jul 2021 10:57:45 -0400 Subject: [PATCH 31/33] Update MenuFrame.java --- src/MenuFrame.java | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/MenuFrame.java b/src/MenuFrame.java index 92bf6ad..313a17e 100644 --- a/src/MenuFrame.java +++ b/src/MenuFrame.java @@ -5,11 +5,7 @@ import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.JOptionPane; -<<<<<<< HEAD -======= -<<<<<<< HEAD ->>>>>>> 0109ac4fce7a09ebf251b40cb3268656f0658869 import java.awt.GridBagConstraints; import java.awt.Insets; import java.awt.BorderLayout; @@ -20,7 +16,7 @@ public class MenuFrame extends JFrame implements ActionListener { -<<<<<<< HEAD + //initialize GUI components JButton nextButton; JButton addIncomeButton; @@ -29,23 +25,14 @@ public class MenuFrame extends JFrame implements ActionListener { MenuFrame() { -======= - // initialize GUI components -======= + + + public class MenuFrame extends JFrame{ + -MenuFrame(){ - - //initialize GUI components ->>>>>>> 10ee06e159cd6e2540b985d8ead3ccc185708b58 - JButton nextButton; - JButton addIncomeButton; - JButton addExpenseButton; - private JButton reportsButton; - -<<<<<<< HEAD public MenuFrame() { ->>>>>>> 0109ac4fce7a09ebf251b40cb3268656f0658869 + @@ -134,9 +121,7 @@ public void actionPerformed(ActionEvent event) { String expenseName = JOptionPane.showInputDialog(expenseFrame,"Enter Expense"); } } -<<<<<<< HEAD -======= -======= + //create JFrame window setTitle("Bank app--Main Menu "); From 9cca7b763704628a56dd4e4260a98fedf3891246 Mon Sep 17 00:00:00 2001 From: MohamedAbusharkh Date: Wed, 21 Jul 2021 13:14:43 -0400 Subject: [PATCH 32/33] menuFrame loads crctly-added rfrnce to brain in allforms,fixed addIcnome --- .project | 2 +- src/EWalletApp.java | 12 +-- src/Expense.java | 6 +- src/LoginFrame.java | 219 +++----------------------------------------- src/MenuFrame.java | 81 ++++++++-------- 5 files changed, 65 insertions(+), 255 deletions(-) diff --git a/.project b/.project index ceb4c39..6d1d6e8 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - 210Project-2021 + 210Project-2021-Julie diff --git a/src/EWalletApp.java b/src/EWalletApp.java index 85d05dd..1d9c3c5 100644 --- a/src/EWalletApp.java +++ b/src/EWalletApp.java @@ -25,22 +25,16 @@ public void CreateUser(String username, String password) {} public static void main(String[] args) { System.out.println("Login"); - LoginFrame lFrame = new LoginFrame(); - - + LoginFrame lFrame = new LoginFrame(brain); String name = ""; - Scanner scnr = new Scanner(System.in); - - + Scanner scnr = new Scanner(System.in); name = scnr.next(); for (User u : AllData) { if (u.username.equals(name)) { brain.userAtHand = u; } - - } if (brain.userAtHand == null) { @@ -68,8 +62,6 @@ public static void main(String[] args) { //adding monthly income //brain.addMonthlyIncome(null); - - } } diff --git a/src/Expense.java b/src/Expense.java index 4a7149a..cae32b9 100644 --- a/src/Expense.java +++ b/src/Expense.java @@ -6,9 +6,9 @@ import java.util.Scanner; public class Expense { - private String source; - private double amount; - private int yearlyFrequency; //1 for 1 time or once a year, 12 for monthly or or 24 for biweekly + String source; + double amount; + int yearlyFrequency; //1 for 1 time or once a year, 12 for monthly or or 24 for biweekly boolean foundDigit = false; boolean foundUpperCase = false; diff --git a/src/LoginFrame.java b/src/LoginFrame.java index b9b7163..6a5edaa 100644 --- a/src/LoginFrame.java +++ b/src/LoginFrame.java @@ -29,7 +29,7 @@ import javax.swing.JFrame; public class LoginFrame extends JFrame implements ActionListener { - + ExpenseCalculator brain; // initialize GUI components JButton nextButton; @@ -38,6 +38,9 @@ public class LoginFrame extends JFrame implements ActionListener { private String password; private JTextField userNameField; private JTextField passwordField; + // initialize GUI components + //JButton nextButton; + // boolean variables boolean foundDigit = false; @@ -81,61 +84,8 @@ public void setPasswordField(JTextField passwordField) { this.passwordField = passwordField; } -<<<<<<< HEAD - - - LoginFrame() { - // initialize GUI components - JButton nextButton; - - // create JFrame window - setTitle("Bank app"); - this.setSize(420, 360); - - // mainPanel - JPanel mainPanel = new JPanel(); - GridBagLayout gbl_mainPanel = new GridBagLayout(); - gbl_mainPanel.columnWidths = new int[] { 93, 50, 104, 56, 0 }; - gbl_mainPanel.rowHeights = new int[] { 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - gbl_mainPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; - gbl_mainPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - Double.MIN_VALUE }; - mainPanel.setLayout(gbl_mainPanel); - getContentPane().add(mainPanel); - - // welcomeLabel - JLabel welcomeLabel = new JLabel("Welcome to Bank App!"); - welcomeLabel.setHorizontalAlignment(SwingConstants.TRAILING); - GridBagConstraints gbc_welcomeLabel = new GridBagConstraints(); - gbc_welcomeLabel.gridwidth = 2; - gbc_welcomeLabel.insets = new Insets(0, 0, 5, 5); - gbc_welcomeLabel.gridx = 1; - gbc_welcomeLabel.gridy = 1; - mainPanel.add(welcomeLabel, gbc_welcomeLabel); - - // userNameLabel - JLabel userNameLabel = new JLabel("Username:"); - GridBagConstraints gbc_userNameLabel = new GridBagConstraints(); - gbc_userNameLabel.anchor = GridBagConstraints.EAST; - gbc_userNameLabel.insets = new Insets(0, 0, 5, 5); - gbc_userNameLabel.gridx = 1; - gbc_userNameLabel.gridy = 3; - mainPanel.add(userNameLabel, gbc_userNameLabel); - - // userNameField - userNameField = new JTextField(); - GridBagConstraints gbc_userNameField = new GridBagConstraints(); - gbc_userNameField.insets = new Insets(0, 0, 5, 5); - gbc_userNameField.fill = GridBagConstraints.HORIZONTAL; - gbc_userNameField.gridx = 2; - gbc_userNameField.gridy = 3; - mainPanel.add(userNameField, gbc_userNameField); - userNameField.setColumns(10); -======= -<<<<<<< HEAD - LoginFrame() { - - + public LoginFrame(ExpenseCalculator brain) { + this.brain=brain; // create JFrame window setTitle("Bank app"); this.setSize(420, 360); @@ -180,54 +130,6 @@ public void setPasswordField(JTextField passwordField) { mainPanel.add(userNameField, gbc_userNameField); userNameField.setColumns(10); userName = userNameField.getText(); -======= - LoginFrame(){ - //initialize GUI components - JButton nextButton; - - //create JFrame window - setTitle("Bank app"); - this.setSize(420, 360); - - // mainPanel - JPanel mainPanel = new JPanel(); - GridBagLayout gbl_mainPanel = new GridBagLayout(); - gbl_mainPanel.columnWidths = new int[] { 93, 50, 104, 56, 0 }; - gbl_mainPanel.rowHeights = new int[] { 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - gbl_mainPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE }; - gbl_mainPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - Double.MIN_VALUE }; - mainPanel.setLayout(gbl_mainPanel); - getContentPane().add(mainPanel); - - // welcomeLabel - JLabel welcomeLabel = new JLabel("Welcome to Bank App!"); - welcomeLabel.setHorizontalAlignment(SwingConstants.TRAILING); - GridBagConstraints gbc_welcomeLabel = new GridBagConstraints(); - gbc_welcomeLabel.gridwidth = 2; - gbc_welcomeLabel.insets = new Insets(0, 0, 5, 5); - gbc_welcomeLabel.gridx = 1; - gbc_welcomeLabel.gridy = 1; - mainPanel.add(welcomeLabel, gbc_welcomeLabel); - - // userNameLabel - JLabel userNameLabel = new JLabel("Username:"); - GridBagConstraints gbc_userNameLabel = new GridBagConstraints(); - gbc_userNameLabel.anchor = GridBagConstraints.EAST; - gbc_userNameLabel.insets = new Insets(0, 0, 5, 5); - gbc_userNameLabel.gridx = 1; - gbc_userNameLabel.gridy = 3; - mainPanel.add(userNameLabel, gbc_userNameLabel); - - // userNameField - userNameField = new JTextField(); - GridBagConstraints gbc_userNameField = new GridBagConstraints(); - gbc_userNameField.insets = new Insets(0, 0, 5, 5); - gbc_userNameField.fill = GridBagConstraints.HORIZONTAL; - gbc_userNameField.gridx = 2; - gbc_userNameField.gridy = 3; - mainPanel.add(userNameField, gbc_userNameField); - userNameField.setColumns(10); // passwordLabel JLabel passwordLabel = new JLabel("Password:"); @@ -248,28 +150,6 @@ public void setPasswordField(JTextField passwordField) { mainPanel.add(passwordField, gbc_passwordField); passwordField.setColumns(10); password = passwordField.getText(); ->>>>>>> 10ee06e159cd6e2540b985d8ead3ccc185708b58 ->>>>>>> 0109ac4fce7a09ebf251b40cb3268656f0658869 - - // passwordLabel - JLabel passwordLabel = new JLabel("Password:"); - GridBagConstraints gbc_passwordLabel = new GridBagConstraints(); - gbc_passwordLabel.anchor = GridBagConstraints.EAST; - gbc_passwordLabel.insets = new Insets(0, 0, 5, 5); - gbc_passwordLabel.gridx = 1; - gbc_passwordLabel.gridy = 4; - mainPanel.add(passwordLabel, gbc_passwordLabel); - - // passwordField - passwordField = new JTextField(); - GridBagConstraints gbc_passwordField = new GridBagConstraints(); - gbc_passwordField.insets = new Insets(0, 0, 5, 5); - gbc_passwordField.fill = GridBagConstraints.HORIZONTAL; - gbc_passwordField.gridx = 2; - gbc_passwordField.gridy = 4; - mainPanel.add(passwordField, gbc_passwordField); - passwordField.setColumns(10); - password = passwordField.getText(); // next button nextButton = new JButton("Next"); @@ -285,57 +165,17 @@ public void setPasswordField(JTextField passwordField) { } -<<<<<<< HEAD -======= -<<<<<<< HEAD ->>>>>>> 0109ac4fce7a09ebf251b40cb3268656f0658869 - public boolean Validate(String userName, String password) throws IOException { - - // open file and starts verifying username and password against the text file - System.out.println("Opening file... "); // Opening file confidentialInfo.txt. - FileInputStream fileByteStream = new FileInputStream("checkLogin.txt"); // created a new fileInputStream - Scanner inFS = new Scanner(fileByteStream); - - System.out.println("Verifying your username and password."); - while (inFS.hasNext()) { - - String verifyUsername = inFS.next(); - String verifyPassword = inFS.next(); - if (userName.equals(verifyUsername) && password.equals(verifyPassword)) { - // create object of the second frame and hide this frame - - return true; - } else { - JOptionPane.showMessageDialog(this, "Username or password not found!"); - } - } - System.out.println("Username not found"); - // close checkLogin.txt file - System.out.println("Closing program..."); - fileByteStream.close(); - return false; - } -<<<<<<< HEAD - /*@Override - public void actionPerformed(ActionEvent e) { - if (e.getSource() == nextButton) { -======= - @Override +/* @Override public void actionPerformed(ActionEvent event) { if(event.getSource() == nextButton) { ->>>>>>> 0109ac4fce7a09ebf251b40cb3268656f0658869 MenuFrame mFrame = new MenuFrame(); userName = userNameField.getText(); System.out.println(userName); password = passwordField.getText(); System.out.println(password); -<<<<<<< HEAD - }}*/ - - - + }} public boolean Validate() throws IOException { // open file and starts verifying username and password against the text file @@ -362,11 +202,10 @@ public boolean Validate() throws IOException { fileByteStream.close(); return false; } -======= } } -======= + */ public boolean Validate() throws IOException { //open file and starts verifying username and password against the text file @@ -381,7 +220,7 @@ public boolean Validate() throws IOException { String verifyPassword = inFS.next(); if (userName.equals(verifyUsername) && password.equals(verifyPassword)){ - JOptionPane.showMessageDialog(this,"login success!"); + JOptionPane.showMessageDialog(this,"login Success!"); return true; } @@ -395,36 +234,6 @@ public boolean Validate() throws IOException { return false; } - @Override - public void actionPerformed(ActionEvent arg0) { - - userName = userNameField.getText(); - System.out.println(userName); - - password = passwordField.getText(); - System.out.println(password); - try { - if (Validate()) { - - // - //TODOs login success message box - // run the menuframe - //create object of the second frame and hide this frame - new MenuFrame(); - //equivalent to --> MenuFrame mFrame = new MenuFrame(); - } - else { - //TODO login failure message box - System.out.println(" failed login try again"); - } - } catch (IOException e) { - System.out.println(" login file exception"); - // TODO Auto-generated catch block - e.printStackTrace(); - } - } ->>>>>>> 10ee06e159cd6e2540b985d8ead3ccc185708b58 ->>>>>>> 0109ac4fce7a09ebf251b40cb3268656f0658869 @Override public void actionPerformed(ActionEvent event) { @@ -436,14 +245,14 @@ public void actionPerformed(ActionEvent event) { System.out.println(password); try { if (Validate()) { - String sucessLogin = null; - sucessLogin = JOptionPane.showInputDialog(sucessLogin,"Success!."); + //String sucessLogin = null; + //sucessLogin = JOptionPane.showInputDialog(this,"Success1!."); //TODOs login success message box // run the menuframe //create object of the second frame and hide this frame - - new MenuFrame(); + JOptionPane.showMessageDialog(this,"login Success!"); + new MenuFrame(brain).setVisible(true); this.setVisible(false); //equivalent to --> MenuFrame mFrame = new MenuFrame(); diff --git a/src/MenuFrame.java b/src/MenuFrame.java index 313a17e..33b11aa 100644 --- a/src/MenuFrame.java +++ b/src/MenuFrame.java @@ -15,27 +15,16 @@ import javax.swing.UIManager; public class MenuFrame extends JFrame implements ActionListener { - - //initialize GUI components - JButton nextButton; - JButton addIncomeButton; - JButton addExpenseButton; - private JButton reportsButton; - - - MenuFrame() { - - + JButton nextButton; + JButton addIncomeButton; + JButton addExpenseButton; + JButton reportsButton; + ExpenseCalculator brain;; -public class MenuFrame extends JFrame{ - - - public MenuFrame() { - - - + public MenuFrame(ExpenseCalculator brain) { + this.brain=brain; // create JFrame window setTitle("Bank app"); this.setSize(420, 360); @@ -96,40 +85,60 @@ public void actionPerformed(ActionEvent arg0) { gbc_reportsButton.gridy = 4; getContentPane().add(reportsButton, gbc_reportsButton); - - - - - - - //create JFrame window - JFrame mainMenu = new JFrame(); +// JFrame mainMenu = new JFrame(); setTitle("Bank app--Main Menu "); + this.setSize(420, 360); + this.setVisible(true); } - @Override public void actionPerformed(ActionEvent event) { if(event.getSource() == addIncomeButton) { JFrame incomeFrame = new JFrame(); - String incomeName = JOptionPane.showInputDialog(incomeFrame,"Enter Income"); + String incomeName = JOptionPane.showInputDialog(incomeFrame,"Enter Income details separated by space, source, amount,month"); + + //using split to read 3 values from 1 field, alternatively add a Jframe specific to add income and have 3 fields in it to read source, amount, month. + String [] incomeResults = incomeName.split(" "); + + Wage w= new Wage(); + w.source=incomeResults[0]; + w.amount= Double.parseDouble(incomeResults[1]); + w.month=incomeResults[2]; + + brain.addMonthlyIncome(w); + + System.out.println(incomeName); } if(event.getSource() == addExpenseButton) { JFrame expenseFrame = new JFrame(); - String expenseName = JOptionPane.showInputDialog(expenseFrame,"Enter Expense"); + String expenseName = JOptionPane.showInputDialog(expenseFrame,"Enter Expense details spearated by space, source, amount,yealry frequency 1 for once a year 12 for monthly"); + + String [] expenseResults = expenseName.split(" "); + + Expense e= new Expense(); + e.source=expenseResults[0]; + e.amount= Double.parseDouble(expenseResults[1]); + e.yearlyFrequency=Integer.parseInt(expenseResults[2]); + + + brain.addExpense(e); + + System.out.println(expenseName); + + } + if(event.getSource() == reportsButton) { + + //TODO add code to print all expenses or income etc etc in PrintFullreport + brain.PrintFullreport(); } } - //create JFrame window - setTitle("Bank app--Main Menu "); - this.setSize(420, 360); + //setTitle("Bank app--Main Menu "); + //this.setSize(420, 360); // mainPanel - JPanel mainPanel = new JPanel(); -} ->>>>>>> 10ee06e159cd6e2540b985d8ead3ccc185708b58 ->>>>>>> 0109ac4fce7a09ebf251b40cb3268656f0658869 +// JPanel mainPanel = new JPanel(); } From d5b2f0bf102a0c7ff0bced1cecf5c0b6629ea838 Mon Sep 17 00:00:00 2001 From: cam Date: Wed, 21 Jul 2021 18:48:01 -0400 Subject: [PATCH 33/33] Fixed addExpense Added reports. --- src/EWalletApp.java | 8 +++++--- src/ExpenseCalculator.java | 14 ++++++++++++++ src/MenuFrame.java | 33 ++++++++++++++++++++++++--------- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/EWalletApp.java b/src/EWalletApp.java index 1d9c3c5..3fe403b 100644 --- a/src/EWalletApp.java +++ b/src/EWalletApp.java @@ -18,8 +18,8 @@ public class EWalletApp { private static ArrayList AllData = new ArrayList(); public void CreateUser(String username, String password) {} - - public static ExpenseCalculator brain = new ExpenseCalculator(); + public static User u = new User(); + public static ExpenseCalculator brain = new ExpenseCalculator(u); @@ -27,7 +27,7 @@ public static void main(String[] args) { System.out.println("Login"); LoginFrame lFrame = new LoginFrame(brain); - String name = ""; + /*String name = ""; Scanner scnr = new Scanner(System.in); name = scnr.next(); @@ -63,5 +63,7 @@ public static void main(String[] args) { //adding monthly income //brain.addMonthlyIncome(null); } + */ } +} diff --git a/src/ExpenseCalculator.java b/src/ExpenseCalculator.java index fb9cd6f..120743b 100644 --- a/src/ExpenseCalculator.java +++ b/src/ExpenseCalculator.java @@ -9,9 +9,15 @@ public class ExpenseCalculator implements Expenser{ + public ExpenseCalculator (User u) { + userAtHand = u; + + } + public User userAtHand; + @Override public void addExpense(Expense Ex) { @@ -21,24 +27,32 @@ public void addExpense(Expense Ex) { @Override public void addMonthlyIncome(Wage W) { + userAtHand.Income.add(W); // TODO Auto-generated method stub } @Override public void PrintFullreport() { + + PrintExpensereport(); + PrintIncomereport(); + + // TODO Auto-generated method stub } @Override public void PrintExpensereport() { + System.out.println(userAtHand.Spending); // TODO Auto-generated method stub } @Override public void PrintIncomereport() { + System.out.println(userAtHand.Income); // TODO Auto-generated method stub } diff --git a/src/MenuFrame.java b/src/MenuFrame.java index 33b11aa..b901721 100644 --- a/src/MenuFrame.java +++ b/src/MenuFrame.java @@ -16,11 +16,12 @@ public class MenuFrame extends JFrame implements ActionListener { //initialize GUI components + JButton ExpenseReportButton; JButton nextButton; JButton addIncomeButton; JButton addExpenseButton; JButton reportsButton; - ExpenseCalculator brain;; + ExpenseCalculator brain; public MenuFrame(ExpenseCalculator brain) { @@ -49,6 +50,17 @@ public MenuFrame(ExpenseCalculator brain) { JLabel welcomeLabel = new JLabel("Welcome!"); mainPanel.add(welcomeLabel); + //Report Expense Button + ExpenseReportButton = new JButton("Print Expense Report"); + ExpenseReportButton.setBackground(UIManager.getColor("Button.disabledForeground")); + ExpenseReportButton.setForeground(UIManager.getColor("CheckBox.foreground")); + ExpenseReportButton.addActionListener(this); + GridBagConstraints gbc_ExpenseReportButton = new GridBagConstraints(); + gbc_ExpenseReportButton.insets = new Insets(0, 0, 5, 0); + gbc_ExpenseReportButton.gridx = 0; + gbc_ExpenseReportButton.gridy = 5; + getContentPane().add(ExpenseReportButton, gbc_ExpenseReportButton); + //Add income button addIncomeButton = new JButton("Add income"); addIncomeButton.setBackground(UIManager.getColor("Button.disabledForeground")); @@ -63,10 +75,8 @@ public MenuFrame(ExpenseCalculator brain) { //add expense button addExpenseButton = new JButton("Add Expense"); addExpenseButton.setBackground(UIManager.getColor("Button.darkShadow")); - addExpenseButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent arg0) { - } - }); + addExpenseButton.addActionListener(this); + GridBagConstraints gbc_addExpenseButton = new GridBagConstraints(); gbc_addExpenseButton.insets = new Insets(0, 0, 5, 0); gbc_addExpenseButton.gridx = 0; @@ -76,15 +86,15 @@ public void actionPerformed(ActionEvent arg0) { reportsButton = new JButton("Reports"); reportsButton.setBackground(UIManager.getColor("Button.disabledForeground")); reportsButton.setForeground(UIManager.getColor("Button.disabledForeground")); - reportsButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent arg0) { - } - }); + reportsButton.addActionListener(this); + GridBagConstraints gbc_reportsButton = new GridBagConstraints(); gbc_reportsButton.gridx = 0; gbc_reportsButton.gridy = 4; getContentPane().add(reportsButton, gbc_reportsButton); + + //create JFrame window // JFrame mainMenu = new JFrame(); setTitle("Bank app--Main Menu "); @@ -133,6 +143,11 @@ public void actionPerformed(ActionEvent event) { //TODO add code to print all expenses or income etc etc in PrintFullreport brain.PrintFullreport(); } + + if(event.getSource() == ExpenseReportButton) { + brain.PrintExpensereport(); + } + } //create JFrame window