Question
Hey there. I have a Java code for a small project which is called Money Manager. The main goal of it is to track your
Hey there. I have a Java code for a small project which is called Money Manager. The main goal of it is to track your income, expenses, etc. I have made the code already but I'm gonna need a few adjustments to the application so it meets the following requirements (Please make sure to apply these and just read what I've written and edit accordingly. Thank you very much! Ok so here are the requirements so I can get a good mark for the code and these need to be fully met: 1. Design 3 to 4 classes - 3 marks 2. Private and public attributes - 0.5 marks 3. Set/get methods - 0.5 marks 4. Two or more constructors - 1 marks 5. Some functionality methods other than setter and getter - 1 marks 6. printDetails method (toString method) - 0.5 marks 7. At least 3 objects in the main method - 0.5 marks 8. Use an array (ArrayList preferable) - 1 marks 9. Write/read from/in file - 1 marks 10. Check input validation - 1 marks Must use aggregation and is logically applied. Here are the classes/codes: User class:
package moneymanager;
import java.util.ArrayList;
public class User { private String name; private ArrayList
public User(String name, ArrayList
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public ArrayList
public void setIncome(ArrayList
public ArrayList
public void setExpenses(ArrayList
-------------- Expense class:
package moneymanager;
public class Expense { private String category; private double amount;
public Expense(String category, double amount) { this.category = category; this.amount = amount; }
public String getCategory() { return category; }
public void setCategory(String category) { this.category = category; }
public double getAmount() { return amount; }
public void setAmount(double amount) { this.amount = amount; } }
------------------ Income class:
package moneymanager;
public class Income { private String source; private double amount;
public Income(String source, double amount) { this.source = source; this.amount = amount; }
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; } }
---------------- Test class:
package moneymanager;
import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.Scanner;
public class Test { private ArrayList
public Test() { users = new ArrayList
public void createUser() { Scanner input = new Scanner(System.in); System.out.print("Enter user name: "); String name = input.nextLine(); User user = new User(name, new ArrayList
public void createIncome() { Scanner input = new Scanner(System.in); System.out.print("Enter user name: "); String name = input.nextLine(); User user = null; for (User u : users) { if (u.getName().equals(name)) { user = u; break; } } if (user == null) { System.out.println("User not found."); return; } System.out.print("Enter source of income: "); String source = input.nextLine(); System.out.print("Enter amount: "); double amount = input.nextDouble(); Income income = new Income(source, amount); user.getIncome().add(income); }
public void createExpense() { Scanner input = new Scanner(System.in); System.out.print("Enter user name: "); String name = input.nextLine(); User user = null; for (User u : users) { if (u.getName().equals(name)) { user = u; break; } } if (user == null) { System.out.println("User not found."); return; } System.out.print("Enter category of expense: "); String category = input.nextLine(); System.out.print("Enter amount: "); double amount = input.nextDouble(); Expense expense = new Expense(category, amount); user.getExpenses().add(expense); } public void addToFile() { try { try (FileOutputStream fos = new FileOutputStream("money-manager.txt"); ObjectOutputStream oos = new ObjectOutputStream(fos)) { oos.writeObject(users); } System.out.println("Data saved successfully to file"); } catch (IOException ioe) { } }
public void readFromFile() { try { try (FileInputStream fis = new FileInputStream("money-manager.txt"); ObjectInputStream ois = new ObjectInputStream(fis)) { users = (ArrayList
public void displayDetails() { for (User user : users) { System.out.println("Name: " + user.getName()); System.out.println("Income:"); ArrayList
After editing what you need to edit in the codes to meet the requirements please provide a UML like the following example: I just need the sorting to be like this, doesn't have to be a drawing. Please EDIT THE CODE before sending it. Make it meet all the requirements i've written. (I already posted this on chegg and the "expert" just provided an explanation for my already existing code without editing it to meet the requirements like I asked??? Also, make sure the addToFile works because I've tried loading from the file or adding to it. I just can't get it to work for some reason. When you finish coding please please please make sure you've met all the requirements and test the application for yourself if it fully works. Then send it. If it doesn't just take your time and edit. I know you can do this :) Thanks!
\begin{tabular}{l} Book \\ \hline -booksNames: \\ ArrayList \\ +price: double \\ +index :int \\ \hline + Book(:) \\ +Book(ArrayList b int i \\ double p): \\ +Book(int i): \\ +setBookNumber(ArrayList \\ b) :void \\ +getBookNumber(): \\ ArrayList \\ + bookList): void \\ + bookPrice(): void \\ +toString(): String \\ \end{tabular}Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started