Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We want to pull together a number of concepts that we have discussed so far in t

ID: 3918503 • Letter: W

Question

We want to pull together a number of concepts that we have discussed so far in the class. We want a menu-driven program that keeps track of plant inventory for a nursery. I have a set of start files for you. Open up PlantDriver.java. This will be our beginning program. There are eight menu items that you need to get working (I did 0, 3 and 8). Run the program (it runs now – but doesn’t do anything except print and quit!). Your goal is to get the menu items to work. Note that the stub methods for the menu items are already written (they are in MenuInfo). These are very similar to many of the tasks we have done in other programs so copy and paste works well for a lot of it. This is really the essence of Java – understand code and reuse as much as you can – do not recreate the wheel. http://prntscr.com/kby4bv

Explanation / Answer

// Plants.java

public class Plants extends Object{

String id;

String description;

int numInStock;

double outCost;

double salesCost;

public Plants() {

System.out.println("D-Cons Plants");

}

public Plants(String id, String description, int numInStock, double outCost, double salesCost) {

System.out.println("5-A-Cons");

this.id = id;

this.description = description;

this.numInStock = numInStock;

this.outCost = outCost;

this.salesCost = salesCost;

}

public boolean equals(Plants arg0) {

return this.equals(arg0);

}

@Override

public String toString() {

return "Plants [id=" + id + ", description=" + description + ", numInStock=" + numInStock + ", outCost="

+ outCost + ", salesCost=" + salesCost + "]";

}

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

public String getDescription() {

return description;

}

public void setDescription(String description) {

this.description = description;

}

public int getNumInStock() {

return numInStock;

}

public void setNumInStock(int numInStock) {

this.numInStock = numInStock;

}

public double getOutCost() {

return outCost;

}

public void setOutCost(double outCost) {

this.outCost = outCost;

}

public double getSalesCost() {

return salesCost;

}

public void setSalesCost(double salesCost) {

this.salesCost = salesCost;

}

}

// MenuInfo.java

import java.util.*;

public class MenuInfo {

List<ArrayList<Plants>> plant = null;

public MenuInfo() {

System.out.println("D-Cons MenuInfo");

}

public ArrayList<Plants> loadPlants(){

return new ArrayList();

}

public ArrayList<Plants> readSerializable(){

return new ArrayList();

}

public void writeSerializable() {

}

public void print(ArrayList<Plants> pl) {

System.out.println(plant);

}

public void total(ArrayList<Plants> pl) {

System.out.println(plant.size());

}

public void find(ArrayList<Plants> pl) {

System.out.println(plant.contains(pl));

}

public void addPlants(ArrayList<Plants> pl) {

plant = new ArrayList<>();

plant.add(pl);

}

public void deletePlants(ArrayList<Plants> pl) {

plant.remove(pl);

}

public void menuAdd() {

}

public void menuDelete() {

}

}

// PlantDriver.java

package com.rio;

import java.util.ArrayList;

import java.util.List;

public class PlantDriver {

public PlantDriver() {

System.out.println("D-Cons PlantDriver");

}

public static void main(String[] args) {

// To add Plant

PlantDriver pd = new PlantDriver();

Plants plt = new Plants();

plt.setId("1");

plt.setDescription("mango");

plt.setSalesCost(5);

plt.setOutCost(3);

plt.setNumInStock(90);

ArrayList<Plants> plant = new ArrayList<>();

plant.add(plt);

MenuInfo mf = new MenuInfo();

mf.addPlants(plant);

// to find plant

mf.find(plant);

// to print all plant

mf.print(plant);

// to delete a plant

mf.deletePlants(plant);

}

public void menu() {

}

}

// As per the question I added the method and its implementation, there are some part where things

// are not clear i.e what actually required, so there I'm not able to write implementation

// there I just written the method, so just add implementations.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote