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...

  • #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a...

    #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a list of up to 10 players and their high scores in the computer's memory. Use two arrays to manage the list. One array should store the players' names, and the other array should store the players' high scores. Use the index of the arrays to correlate the names with the scores. Your program should support the following features: a. Add a new player 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,  Id number, Courses, and Date, where: Name is a user defined class comprising of at minimum first name and last name. The field Courses is a set of no more than five (5) string values representing the courses being registered for. Course names supplied are assumed to...

  • 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;...

  • Java Project For this assignment, you will write a simulation program to determine the average waiting...

    Java Project For this assignment, you will 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 instead include a single add method...

  • 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...

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