Question

I need to make a project named CStore. It is a Java starter project that only...

I need to make a project named CStore.
It is a Java starter project that only uses the console.
I don't know how to even start it..
Please help me asap

First I need to define 3 classes names Goods, Manage, UI.
Then simply implement the Goods class, then make a function that inserts Goods object into a Goods list in the Manage class.
In the UI class, the user inputs Goods that will be registered and that Goods will be inputed in the Goods List in the Manage class.

First screen will say 1. user 2. manager
If you choose 2, which is the manager, the next ouput is
1. input
2. output
3. end program
When you enter 1, you should enter new Goods info (details below) (the product number(ID) should be automatically given)
WHen you enter 2, it ouputs every item you just registered.
If you wnat you could use try~~catch in this UI part.

The Goods class whould have the following data member and member funtion.
-larger group name (ex. juice-> orange juice, lemonade, juice is the larger group name and lemonade if the product name)
-product name
-price
-product number(ID) (that should be automatically given when registered)
-remaining stock
+add stock
+remove stock

There should be an array in the Mangage class that contains Goods objects,
and there should be a member function that manages this array.

It would mean alot if someone could help me..

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Goods.java

public class Goods {
private int productId;
private String productName;
private double productPrice;
  
public Goods()
{
this.productId = 0;
this.productName = "";
this.productPrice = 0;
}

public Goods(String productName, double productPrice)
{
this.productId = (int)(Math.random() * 100) + 10; // generates random number between 10 & 100
this.productName = productName;
this.productPrice = productPrice;
}

public int getProductId() {
return productId;
}

public String getProductName() {
return productName;
}

public double getProductPrice() {
return productPrice;
}
  
@Override
public String toString()
{
return("Id: " + getProductId() + ", Name: " + getProductName()
+ ", Price: $" + String.format("%.2f", getProductPrice()));
}
}

Manage.java

import java.util.ArrayList;

public class Manage {
private ArrayList<Goods> goodsList;
  
public Manage()
{
this.goodsList = new ArrayList<>();
}
  
public Manage(ArrayList<Goods> goodsList)
{
this.goodsList = goodsList;
}

public ArrayList<Goods> getGoodsList()
{
return goodsList;
}
  
public void addStock(Goods good)
{
this.goodsList.add(good);
System.out.println("\n" + good.getProductName() + " added successfully!");
}
  
public void removeStock(int id)
{
boolean found = false;
int index = 0;
for(int i = 0; i < this.goodsList.size(); i++)
{
if(this.goodsList.get(i).getProductId() == id)
{
found = true;
index = i;
break;
}
}
if(!found)
System.out.println("\nNo product with product id " + id + " was found!");
else
{
System.out.println("\nProduct " + this.goodsList.get(index).getProductName() + " was removed successfully!");
this.goodsList.remove(index);
}
}
}

UI.java (Main class)

import java.util.ArrayList;
import java.util.Scanner;

public class UI {
  
public static void main(String[]args)
{
Scanner sc = new Scanner(System.in);
int choice1 = 0, choice2 = 0;
ArrayList<Goods> goodsList = new ArrayList<>();
  
goodsList.add(new Goods("Juice", 14.56));
goodsList.add(new Goods("Lemonade", 11.50));
goodsList.add(new Goods("Sandwich", 31.00));
goodsList.add(new Goods("Pizza", 50.00));
goodsList.add(new Goods("Cold Drink", 24.20));
  
Manage manage = new Manage(goodsList);
  
do
{
printMainMenu();
choice1 = sc.nextInt();
switch(choice1)
{
case 1:
System.out.println("\n*** ALL GOODS ***\n-----------------");
for(Goods goods : manage.getGoodsList())
{
System.out.println(goods.toString());
}
System.out.println();
break;
  
case 2:
do
{
System.out.println();
printSubMenu();
choice2 = sc.nextInt();
sc.nextLine();
switch(choice2)
{
case 1:
System.out.print("\nEnter product name: ");
String name = sc.nextLine().trim();
System.out.print("Enter product price: $");
double price = sc.nextDouble();
manage.addStock(new Goods(name, price));
System.out.println();
break;
  
case 2:
System.out.println("\n*** ALL GOODS ***\n-----------------");
for(Goods goods : manage.getGoodsList())
{
System.out.println(goods.toString());
}
System.out.println();
break;
  
case 3:
System.out.println("\nGood bye!\n");
System.exit(0);
}
}while(choice2 != 3);
break;
  
case 3:
System.out.println("\nGood bye!\n");
System.exit(0);
}
}while(choice1 != 2);
  
}
  
public static void printMainMenu()
{
System.out.print("1. User\n2. Manager\n3. End program\nChoose user type: ");
}
  
public static void printSubMenu()
{
System.out.print("1. Input\n2. Output\n3. End program\nEnter your choice: ");
}
}

************************************************************************* SCREENSHOT **************************************************

Add a comment
Know the answer?
Add Answer to:
I need to make a project named CStore. It is a Java starter project that only...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is a Java project. It has alot of details T.T The project only uses the CONSOLE! I am looking for many ways to solv...

    This is a Java project. It has alot of details T.T The project only uses the CONSOLE! I am looking for many ways to solve this project so if you have the time, please try it! It means so much!! This is a store management system. It has 3 classes. (Goods, Management, UI)  There should be an array in the Management class contains Goods objects, and there should be a function that manages this array, meaning adding and deleting objects,...

  • In JAVA #3 Write a program named nameChanger.java. This program will only have a driver class...

    In JAVA #3 Write a program named nameChanger.java. This program will only have a driver class with a main. This program will have the user enter a series of names(first and last), which will then be stored in a String array. You will then change the values of each of the names in the array, so that they are stored lastname, firstname, and then output the revised array. Sample: Enter a name (first and last): Tonya Pierce Enter a name...

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class...

    PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class has 4 attributes: (1) student ID: protected, an integer of 10 digits (2) student name: protected (3) student group code: protected, an integer (1 for undergraduates, 2 for graduate students) (4) student major: protected (e.g.: Business, Computer Sciences, Engineering) Class Student declaration provides a default constructor, get-methods and set-methods for the attributes, a public abstract method (displayStudentData()). PART II: Create a Java class named...

  • 2. Write a program named lab3 2.app that contains a class named Student to store student...

    2. Write a program named lab3 2.app that contains a class named Student to store student information Information that will be relevant to store is first name, last name, id number, GPA, and major (1) Define a member function named set0, which allows you to set all member variables. This function has an empty parameter list, and its return type is void. So, within the function you'll prompt for information. Note: For entering major, if you need a space, use...

  • I need help with this java project and please follow the instruction below. thank Class Project...

    I need help with this java project and please follow the instruction below. thank Class Project - Parking Ticket simulator Design a set of classes that work together to simulate a police officer issuing a parking ticket. Design the following classes: •           The ParkedCar Class: This class should simulate a parked car. The class’s responsibilities are as follows: – To know the car’s make, model, color, license number, and the number of minutes that the car has been parked. •          ...

  • Java Project In Brief... For this Java project, you will create a Java program for a...

    Java Project In Brief... For this Java project, you will create a Java program for a school. The purpose is to create a report containing one or more classrooms. For each classroom, the report will contain: I need a code that works, runs and the packages are working as well The room number of the classroom. The teacher and the subject assigned to the classroom. A list of students assigned to the classroom including their student id and final grade....

  • You will turn in a java file named "MyMethods.java". It will contain one class named "MyMethods". That class will contain three methods. These methods must be in JOptionPane and must c...

    You will turn in a java file named "MyMethods.java". It will contain one class named "MyMethods". That class will contain three methods. These methods must be in JOptionPane and must contain: getAnInt will return a value of type int, and take as an argument a string to prompt the user. The actual prompt presented to the user should include not only the string argument, but also the information that the user may press Cancel or enter an empty string to...

  • This assignment will continue our hardware store system. You will turn in a java file named...

    This assignment will continue our hardware store system. You will turn in a java file named "MyMethods.java". It will contain one class named "MyMethods". That class will contain three methods. These methods must be exactly as specified (including method names): getAnInt will return a value of type int, and take as an argument a string to prompt the user. The actual prompt presented to the user should include not only the string argument, but also the information that the user...

  • I need to get this two last parts of my project done by tonight. If you...

    I need to get this two last parts of my project done by tonight. If you see something wrong with the current code feel free to fix it. Thank you! Project 3 Description In this project, use project 1 and 2 as a starting point and complete the following tasks. Create a C++ project for a daycare. In this project, create a class called child which is defined as follows: private members: string First name string Last name integer Child...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT