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, while giving the product their
IDs.
A Goods object should have the following data memebers and
functions.
: categoryName (for example, the category might be 'drinks' and the
product name could be lemonade, cola, sprite etc.), name, price,
stock, id (which is the product number, the index number of the
product)
:addStock, removeStock, and the get/set functions
(There should be a 'totalSales' variable to keep up with the total of the store's sales, but I couldn't decide where to put it.)
In the UI, the first screen should say
1. user
2. manager
3. end
----------
enter number of task:
When you enter 1, this is a customer buying products.
First ask the user which product they want to buy, and how many.
(Ask and receive input about the category->product->number)
Then you tell the user how much each product costs and how much the
total is. If the user agrees to buy the products, the stock should
go down and the total sales should go up. If there is no stock left
of the product the user wants to purchase, get the exception and
tell the user that there is no stock left.
There should be a int sellEstimate(int index, int sellCount)
function which returns how much it costs to buy 'sellCount' amount
of the product named 'index'. There could be an exception made
here.
int sell(int index, int sellCount) is a function which after the
user agrees to buy the products, reduces the stock, increases the
sales total, and returns the total of the user purchase. There
needs to be a excepttion or try catch, in case there is no stock
left.
When you enter 2, the second screen shows
1. insert
2. output (shows list of the new products inserted)
3. find product
4. delete
5. show category
6. go back
----------
enter number of task:
When you enter 1, you should enter new Goods info. The
product number should be automatically given to the product. The
product number should be the index number in the Goods list.
When you enter 2, it outputs every item you just registered in the
console.
When you enter 3, int findGoodsIndex(String goodsName) in the
Management class returns the index number of the perimeter that has
to be found.
When you enter 4, void deleteGoods(int index) deletes the index in
the goods array of the product.
When you enter 5, in the Management class, there should be a
findGoods(String categoryName) function the returns all the
products that are in the category named.
When you enter 6, you go back to the first UI screen.
In all the functions or most of them (I think most of them need it), it sould throw an exception if there is no product that you are looking for, or no catefory, or no stock left.
Yeah three files.. Goods, Management, UI maybe four for the user info
Goods.java :
package store;
public class Goods {
private String categoryName;
private String name;
private double price;
private int stock;
private int id;
public Goods(String category,String name){
this.categoryName = category;
this.name = name;
this.price = 0.0;
this.stock = 0;
this.id = 0;
}
public void addStock(int stock){
this.stock = this.stock+
stock;
}
public double removeStock(int stock){
this.stock = this.stock -
stock;
return this.stock*price;
}
public double getPrice(){
return price;
}
public void setPrice(double price){
this.price = price;
}
public int getStock(){
return this.stock;
}
public int getID(){
return id;
}
public String getCategory(){
return this.categoryName;
}
public String getName(){
return this.name;
}
public void setID(int id){
this.id = id;
}
}
Management.java:
package store;
import java.util.ArrayList;
import javax.naming.directory.InvalidAttributesException;
public class Management {
private ArrayList<Goods> goods;
private double totalSells;
public Management(){
goods = new
ArrayList<Goods>();
totalSells = 0;
}
public void add(Goods g){
g.setID(goods.size()+1);
goods.add(g);
}
public void delete(int id){
goods.remove(id);
}
public boolean isCategory(String category) {
for(int
i=0;i<goods.size();i++){
if(goods.get(i).getCategory().compareTo(category)==0){
return true;
}
}
return false;
}
public int getProductId(String name) {
for(int
i=0;i<goods.size();i++){
if(goods.get(i).getName().compareTo(name)==0){
return i;
}
}
return -1;
}
public void sell(int id, int number) {
try {
if(goods.get(id).getStock()<number){
throw new InvalidAttributesException("Not enough
produt for sell.");
}
else{
totalSells = totalSells +
goods.get(id).removeStock(number);
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public double sellEstimate(int id, int number) {
return
goods.get(id).getPrice()*number;
}
public void printItems() {
for(int
i=0;i<goods.size();i++){
System.out.print("Product ID : ");
System.out.println(i);
System.out.print("Product Category : ");
System.out.println(goods.get(i).getCategory());
System.out.print("Product Name : ");
System.out.println(goods.get(i).getName());
System.out.print("Product Price : ");
System.out.println(goods.get(i).getPrice());
System.out.print("Product Quantity : ");
System.out.println(goods.get(i).getStock());
}
}
public void findGoods(String categoryName) {
for(int
i=0;i<goods.size();i++){
if(goods.get(i).getCategory().compareTo(categoryName)==0){
System.out.print("Product Name : ");
System.out.println(goods.get(i).getName());
System.out.print("Product Price : ");
System.out.println(goods.get(i).getPrice());
System.out.print("Product Quantity : ");
System.out.println(goods.get(i).getStock());
}
}
}
}
UI.java:
package store;
import java.util.Scanner;
import javax.naming.directory.InvalidAttributesException;
public class UI {
public static void main(String[] args){
Management m = new
Management();
boolean repeat = true;
while(repeat){
Scanner in = new
Scanner(System.in);
int input =
0;
double cost =
0.0;
int amt =
0;
try{
System.out.println("Select from menu:");
System.out.println("1. user");
System.out.println("2. manager");
System.out.println("3. end");
input =
in.nextInt();
if(input>3 ||
input<1){
throw
new InvalidAttributesException("Invalid input.");
}
}
catch(Exception e){
System.out.println(e.getMessage());
}
switch (input) {
case 1:
System.out.println("Which product they want to
buy?");
System.out.println("Enter Category : ");
String category = in.next();
if(!m.isCategory(category)){
System.out.println("No such
Category! ");
break;
};
System.out.println("Enter product Name :
");
String name = in.next();
int id = m.getProductId(name);
if(id == -1){
break;
}
System.out.println("How many you want to buy?
");
int number = in.nextInt();
cost = m.sellEstimate(id,number);
System.out.print("Total amount to be paid :
");
System.out.println(cost);
if(cost == -1){
break;
}
else{
m.sell(id,number);
}
break;
case 2:
try{
System.out.println("Select from menu:");
System.out.println("1.
insert");
System.out.println("2. output
(shows list of the new products inserted)");
System.out.println("3. find
product");
System.out.println("4.
delete");
System.out.println("5. show
category");
System.out.println("6. go
back");
input = in.nextInt();
if(input>6 ||
input<1){
throw
new InvalidAttributesException("Invalid input.");
}
}
catch(Exception
e){
System.out.println(e.getMessage());
}
switch (input) {
case 1:
System.out.println("Enter new
product Category : ");
String category1 =
in.next();
System.out.println("Enter
product name : ");
String name1 =
in.next();
Goods g = new
Goods(category1, name1);
System.out.println("Set price
of product : ");
cost = in.nextDouble();
g.setPrice(cost);
System.out.println("Enter
product quantity : ");
amt = in.nextInt();
g.addStock(amt);
m.add(g);
break;
case 2:
m.printItems();
break;
case 3:
System.out.println("Enter
product name : ");
String name2 =
in.next();
System.out.print("Product ID
is : ");
System.out.println(m.getProductId(name2));
break;
case 4:
System.out.println("Enter
product id to Delete : ");
int id1 = in.nextInt();
m.delete(id1);
break;
case 5:
System.out.println("Enter
product Category : ");
String categoryName =
in.next();
m.findGoods(categoryName);
break;
case 6:
break;
default:
break;
}
break;
case 3:
repeat = false;
break;
default:
break;
}
}
}
}
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...
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...
I was wondering if I could get some help with a Java Program that I am currently working on for homework. When I run the program in Eclipse nothing shows up in the console can you help me out and tell me if I am missing something in my code or what's going on? My Code: public class Payroll { public static void main(String[] args) { } // TODO Auto-generated method stub private int[] employeeId = { 5658845, 4520125, 7895122,...
In this project you will create a console C++ program that will have the user to enter Celsius temperature readings for anywhere between 1 and 365 days and store them in a dynamically allocated array, then display a report showing both the Celsius and Fahrenheit temperatures for each day entered. This program will require the use of pointers and dynamic memory allocation. Getting and Storing User Input: For this you will ask the user how many days’ worth of temperature...
c++. please show screenshots of output This project will continue to familiarize the student with using arrays. Store all the function proto-types in project11_funch and store all the functions in project11_func.cpp. Make sure you have proper header comments in each.h,.cpp file. When you run your program, your sample output should show your name. Your report should include the following: 1) project11_func.h 2) project11_func.cpp 3) project11.cpp 4) sample output Write the following functions: a) void fill_array_with_random_nums(int array(), int N): Fill array...
DONE IN C++ ONLY. C++ C++ This week you should get some experience with I reporting errors from functions using exceptions I writing templated functions Part 1 1. Implement the linear and binary search functions. Each function should take as a formal parameter an array of integers (of size less than 100) and returns (a) in the case of successful search – the position (index) of the target in the array (b) in the case of unsuccessful search – an...
I am struggling with a program in C++. it involves using a struct and a class to create meal arrays from a user. I've written my main okay. but the functions in the class are giving me issues with constructors deconstructors. Instructions A restaurant in the Milky way galaxy called “Green Alien” has several meals available on their electronic menu. For each food item in each meal, the menu lists the calories per gram and the number of grams per...
CSC151 Stock Portfolio GUI Project Goal You are to write a GUI program that will allow a user to buy, sell and view stocks in a stock portfolio. This document will describe the minimum expected functions for a grade of 90. Your mission is to “go and do better.” You’ll find a list of enhancement options at the end of this document. Objectives By the end of this project, the student will be able to • write a GUI program...
All code will be in Java, and there will be TWO source code. I. Write the class MailOrder to provide the following functions: At this point of the class, since we have not gone through object-oriented programming and method calling in detail yet, the basic requirement in this homework is process-oriented programming with all the code inside method processOrderof this class. Inside method processOrder, we still follow the principles of structured programming. Set up one one-dimensional array for each field: product...
I need help making this work correctly. I'm trying to do an array but it is drawing from a safeInput class that I am supposed to use from a previous lab. The safeInput class is located at the bottom of this question I'm stuck and it is not printing the output correctly. The three parts I think I am having most trouble with are in Bold below. Thanks in advance. Here are the parameters: Create a netbeans project called ArrayStuff...