Coquitlam College CSCI127A
INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING – LABORATORY
Final Project: Grocery Store System
Megan O’Connor Summer 2019 Due: July 12, 2019, 10PM
“You have been asked to create a simple grocery store system to help organize the grocery store on a computer. The system will be operated by the cashier.
The Grocery Store System will allow customers to buy items from the store. To buy an item it is first searched for in the store by its item number, then the system requests the amount of this item the customer wishes to buy, it will then calculate the cost of those items. Once all items have been entered the system will calculate the final cost of all the items, include the GST.
The cashier should also be able to add items to the system, by providing a description. As well as edit and remove existing items from the system.”
For your project, you will first implement an Item class. The Item class will have the following instance fields:
stock: how many of the item are currently in stock at the store
And the following instance methods:
a constructor with four parameters
an accessor method for each field
a mutator method for each field
buy(int amount): removes the amount from stock and returns the cost of the items
based on price
The Item class will also have the following static field
And the follow static methods:
You will then complete the implementation of the GroceryStore application. The application uses an array of Item objects to represent the store. Each of the four features of the system (add, edit, delete, buy) is implemented as a static method. There is also a static method sort which sorts the Item array by the items’ numbers and a static method binarySearch which searches the Item array by the item’s number.
addItem(): adds a new Item object to the Item array and then sorts the array by itemNumber using the static method sort.
editItem(): searches the Item array for an Item object using the binarySearch method, then allows the user to edit the fields of the Item object. The user should be able to choose which field they wish to edit and can edit multiple fields if they choose. Once the use is finished editing fields, the array is resorts the array using the static method sort.
Coquitlam College CSCI127A Megan O’Connor INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING –
LABORATORY Summer 2019
deleteItem(): searches the Item array for an Item object using the binarySearch method, then removes the Item object from the array.
buyItems(): allows the user to buy items from the store. For each item, it searches the Item array for an Item object using the binarySearch method, it then asks for the amount of Items to buy and the cost of the items is added to the total cost. After all items are bought, it adds the GST to the total cost and prints the final amount to the user.
binarySearch(int itemNumber): implements a binary search on the Item array (Do NOT use any search methods provided in the Java API).
sort(): sorts the Item array by itemNumber using one of the sorting algorithm discussed in class (Do NOT use any sorting methods provided in the Java API).
To be handed in:
Your source files Item.java and GroceryStore.java. Include documentation comments for all methods and use proper indentation and descriptive variable names in all files. Remember to include any necessary input validation and error handling.
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: [email protected] 微信:dmxyzl003