Question

You have to write a java solution for a store. Part 1 The solution needs to...

You have to write a java solution for a store.

Part 1

The solution needs to have at least following features:

◦ Item: Name, ID (incremental ID by 1 for each product), Price.

◦ Store Basket: ID (incremental ID by 1 for each basket), Net Amount, Total Amount, VAT, List of items, Date and Time of purchase, Address of the store, name of cashier.

◦ Cashier: Name, Surname, Username and Password (insert from code five fixed cashiers).

◦ Manager: Name, Surname, Username and Password (insert from code one fixed manager).

The program must:

 Present a Menu for the cashier after he has logged in with username and password.

 Menu should be available in 2 languages.

Menu:

◦ New Basket

◦ Insert item in basket

◦ Remove item from basket

◦ Print information for basket with a certain ID

◦ Apply discount to basket with 10% for Christmas promotion

◦ Exit

Extend four classes: Item, StoreBasket, Store, Cashier.

USE JAVA TO WRITE CODE

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

Answer;

import java.util.ArrayList; import java.util.Iterator; public class GroceryStore { ArrayList myItems; /* Creates an initially empty grocery store / public GroceryStore() { myItems = new ArrayList(); } /* Changes the price of the item associated with itemName / public void setPrice(String itemName, double price) { GroceryItem item = getItem(itemName); if (item != null) { ( (GItem) item).price = price; } } /* returns the item associated with itemName / public GroceryItem getItem(String itemName) { return getGItem(itemName); } /* returns a (possibly empty) ArrayList of all the items in the specified category / public ArrayList getAllItems(String category) { ArrayList list = new ArrayList(); for(int k=0; k < myItems.size(); k++) { GItem item = (GItem) myItems.get(k); if (item.getCategory().equals(category)) { list.add(item); } } return list; } /* precondition: names.length == prices.length changes the price of the item associated with names[k] to the price specified by prices[k] / public void changePrices(String[] names, double[] prices) { for(int k=0; k < names.length; k++) { setPrice(names[k],prices[k]); } } private GItem getGItem(String itemName) { Iterator it = myItems.iterator(); while (it.hasNext()) { GItem gitem = (GItem) it.next(); if (gitem.getName().equals(itemName)) { return gitem; } } return null; } private class GItem implements GroceryItem { String name; double price; String category; int size; public String getName() { return name; } public double getPrice() { return price; } public int getSize() { return size; } public String getCategory() { return category; } } }

Add a comment
Know the answer?
Add Answer to:
You have to write a java solution for a store. Part 1 The solution needs to...
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
  • Java Inventory Management Code Question

    Inventory ManagementObjectives:Use inheritance to create base and child classesUtilize multiple classes in the same programPerform standard input validationImplement a solution that uses polymorphismProblem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes...

  • InventoryManagement

    Problem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes re-ordering the menu items and making changes to the description of a menu item without having to change the code.Security:The company has...

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

  • Write a Java program which will store, manipulate, and print student registration information. As part of...

    Write a Java program which will store, manipulate, and print student registration information. As part of the solution, identify the following classes: Student Admissions. The class Student must have the following fields – Name, Address, Id number, Courses, and Date, where: Name is a user defined class comprising of at minimum first name and last name. Address is a user defined class comprising of fields - street, city, state, and zip code. Date is a predefined class in the java.util...

  • Written in Java I have an error in the accountFormCheck block can i get help to...

    Written in Java I have an error in the accountFormCheck block can i get help to fix it please. Java code is below. I keep getting an exception error when debugging it as well Collector.java package userCreation; import java.io.IOException; import java.net.URL; import java.util.ResourceBundle; import java.util.regex.Matcher; import java.util.regex.Pattern; import javafx.event.ActionEvent; import javafx.fxml.*; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.text.Text; import javafx.stage.*; public class Controller implements Initializable{ @FXML private PasswordField Password_text; @FXML private PasswordField Confirm_text; @FXML private TextField FirstName_text; @FXML private TextField LastName_text;...

  • Can you help me with a Java Code: We are to write software for the checkout...

    Can you help me with a Java Code: We are to write software for the checkout system of a video game rental store. Note: You are not writing the entire checkout system. You are responsible for writing (and testing!) only the age-restricted part of the system. The specification for your system is as follows: At the start of each rental transaction, the system will first scan a barcode to do a customer lookup. (Assume other people in the company will...

  • Java Computer Labs Assignment! The code NEEDS to be commented properly! Every class file should have a header comment that includes your name and assignment number and briefly documents what the prog...

    Java Computer Labs Assignment! The code NEEDS to be commented properly! Every class file should have a header comment that includes your name and assignment number and briefly documents what the program does! If there are known deficiencies with your program such as known problems or incomplete features, these should be clearly listed in the header comment! Every method should have a method header comment that documents what the method does, what its parameters are, and what it returns! You...

  • Assignment 1. You are to write a simple program using Netbeans Java IDE  that consists of two...

    Assignment 1. You are to write a simple program using Netbeans Java IDE  that consists of two classes. The program will allow the user to place an order for a Tesla Model X car. 2. Present the user with a menu selection for each option on the site. We will use JOptionPane to generate different options for the user. See the examples posted for how to use JOPtionPane. 3. Each menu will have multiple items each item will be in the...

  • Need three seperate files. ShoppingCartManager.java ShoppingCart.java ItemsToPurchase.java These are from part 1 what do you mean...

    Need three seperate files. ShoppingCartManager.java ShoppingCart.java ItemsToPurchase.java These are from part 1 what do you mean by deep study 7.25 LAB*: Program: Online shopping cart (Part 2) Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input This program extends the earlier Online shopping cart program (Consider...

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