Question
Now that we've found a way to replace our lost items and are well on our way to getting back on the road we decide
Now that we've found a way to replace our lost items and are well on our way to getting back on the road we decide that we should think about implementing additional features (at a much higher cost!) for those businesses who feel they can afford a bit more. By doing this, we will not only be able to replace our stolen items, but also leave Alexander and Elizabeth with a little nest egg of their own, maybe large enough to hire a doctor to treat Elizabeth. Every shop owner who has our pack absolutely loves it, but wishes they didn't have to empty it out each night and put everything back in the next morning. We've heard of a way to store the pack so it can be easily saved and when reopened everything is as fresh as the previous day.
Using your midterm solution implement an option to save the plants to a file. You must also be able to load the saved information from a previously saved file. All previously required actions are still required (add, remove, display, etc)
You are allowed to use any file saving and loading methods.
You MUST submit a sample file that can be loaded into your program without any changes (except the file path)
Submit 6 files: Assignment4.java, flower.java, fungus.java, plant.java, weed.java and the example sample.txt. Below are the 6 codes that need to be altered.
Main Code:
import java.io.*;
import java.util.*; import javax.swing.*; public class mid { public static void main(String args) throws IOException { Scanner input = new Scanner(System.in); ArrayList
public static void add(ArrayList
private static void remove(ArrayList
private static void display(ArrayList
public static void search(ArrayList
public static void filter(ArrayList
public static void saveLoad(ArrayList Plant public class plant { private String ID; private String name; private String color; public plant() { } public plant(String id, String n, String c) { ID = id; name = n; setColor(c); } public void setId(String id) { ID = id; } public String getId() { return ID; } public void setName(String n) { name = n; } public String getName() { return name; } public void setColor(String color) { this.color = color; } public String getColor() { return color; } } Flower public class flower extends plant { private String thorns; private String smell; private String id; private String name; public flower() { } public flower(String ID, String name, String color, String thorns, String smell) { super(ID, name, color); this.thorns = thorns; this.smell = smell; id = ID; this.name = name; } public void setThorns(String thorns) { this.thorns = thorns; } public void setSmell(String smell) { this.smell = smell; } public String getThorns() { return thorns; } public String getSmell() { return smell; } public String toString() { return id + " " + name + " " + getColor() + " " + thorns + " " + smell; } } Fungus public class fungus extends plant { private String poisonous; private String id; private String name; public fungus() { } public fungus(String ID, String name, String color, String poisonous) { super(ID, name, color); this.poisonous = poisonous; id = ID; this.name = name; } public void setPoisonous(String poisonous) { this.poisonous = poisonous; } public String getPoisonous() { return poisonous; } public String toString() { return id + " " + name + " " + getColor() + " " + poisonous; } } Weed public class weed extends plant { String poisonous; String edible; String medicinal; String id; String name; public weed() { } public weed(String ID, String name, String color, String poisonous, String edible, String Medicinal) { super(ID, name, color); this.poisonous = poisonous; this.edible = edible; this.medicinal = medicinal; id = ID; this.name = name; } public void setPoisonous(String poisonous) { this.poisonous = poisonous; } public void setEdible(String edible) { this.edible = edible; } public void setmedicinal (String medicinal) { this.medicinal = medicinal; } public String getPoisonous() { return poisonous; } public String getEdible() { return edible; } public String getMedicinal() { return medicinal; } public String toString() { return id + " " + name + " " + edible + " " + medicinal + getColor() + " " + poisonous; } }
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