Coder Social home page Coder Social logo

f21as-project's People

Contributors

jonleesy avatar kymckay avatar linarietuma avatar mohamed-arif avatar yeshwanthraj19 avatar

Watchers

 avatar  avatar

f21as-project's Issues

Implement OrderBasket

Result of @jonleesy and I's discussion today on reworking some of our class structure to break the overly complex linking between menu items and order items (which made the OrderList file parsing overly complicated as it had to be aware of class instances we hadn't planned for):

  • Extends OrderList
  • Constructor: OrderBasket(Menu, OrderList)
    • Uses Menu to instantiate a Map of all item IDs to integer values in order to track the number of times each was ordered for the final report
    • Uses OrderList to checkout to later on when checkout() is called
  • private method: applyDiscount()
    • Runs each time an item is added (override add method)
    • Evaluates contents of basket to determine if discount applies
    • Stores discount on Order instances
  • checkout()
    • Update the tally of ordered MenuItems
    • Dump basket contents into supplied OrderList

Add kitchen staff

  • Serving staff will take the order (some time to enter into till)
  • Order is passed to a queue for kitchen staff to prepare
  • Order will be prepared by kitchen staff (some time passes)

Introduce Customer class

Something we've discussed before, but I think this is more relevant now that we are actually "simulating" transactions and will probably want the customer's names for the UI too.

This would involve:

  • Moving the customer ID into the customer class (generated from their name, accounting for multiple customers with the same initials)
  • Linking a Customer instance to each Order instead of just their ID

Implement the MenuItem class

  • id: String
  • basePrice: BigDecimal
  • description: String
  • MenuItem(String id, BigDecimal price, String description): void
  • getId(): String
  • getDescription(): String
  • getBasePrice(): BigDecimal

Implement the Beverage class

Inherits from #1
Uses #14

  • sizes: Size []
  • canBeHot: bool
  • milks: Milk []
  • Beverage(Size [] sizes, bool canBeHot, Milk [] milks): void
  • getSizes(): Size []
  • canBeHot(): bool
  • getMilks(): Milk []

Add a producer thread

We need a producer class running as a thread to add orders into the shared object (queue) after reading them in from the file.

The additions should happen gradually so some sleep should be added.

Use StringBuilder for output report

Currently our output report is constructed using repeated string concatenation.

A StringBuilder would be more suitable for this scenario as it's more efficient especially if we're to assume the menu contains many items.

This is just a simple refactor and shouldn't change the behaviour at all.

Write output report file

  1. On gui branch exists the OrderBasket class so you'll need to work from there
  2. The Menu class should have the getReport method removed
  3. The OrderList class should have the writeFile method removed
  4. The OrderBasket class needs a method writeReport which has a String parameter representing the file name to write to.

The method should:

  • Iterate through the entire menu and for each item write a line to the file in the form: ID: NumTimesOrdered (Description). These will all be fields you can access on the MenuItem instances (number of times ordered not yet implemented at time of writing).
  • Write out some summary information for that day. At minimum (required) the total income of all orders that day. Other ideas would be the customer who spent most and how much. The most ordered item in the morning, afternoon and evening. This will be the difficult part, as you'll need to edit OrderList itself to expose the information you need.

Beverages options not making sense

Issue is related to previously brought up issue #51

Issue1:
Water is prices at 2,.00 and with option L only.

  • Hence the shown price is 3.00 where 2 x L = 2 x 1.5 = 3.00
  • not affected when added to basket
  • same goes to orange and apple juice

Issue 2:
Items that has size options M|L shows a different base price than expected price

  • same as issue 1 above,
  • Sizes should instead be changed to S|M instead of M|L

Add priority queue

"Allow customers to order online in advance. These orders could be handled using an additional queue that has priority over the main customer queue."

The key thing here is the addition of a second queue which the staff should prioritise orders from over the other queue.

Implement the OrderList class

Stores instances of #6

  • orderList: LinkedList
  • OrderList(): void
  • readFile(String fileName): void
  • processLine(String line): void
  • writeToFile(String fileName, String input)
  • add(Order o): boolean
  • getReport(): String
  • getTotalIncome(): BigDecimal

Fix discount2 bug

The lunchtime discount works a bit weird when item with price under £2 (e.g. honey) is added. Any subsequently added beverages get a price change to £2 despite having a single food item in the food basket.
Have a feeling it has to do with the negative discount. Alternatively we could just remove/increase price for all item under £2 as it only seems to affect those items.

Implement the Merchandise class

Inherits from #1
Uses #14

  • labels: Label []
  • colours: Colour []
  • Merchandise(Label [] labels, Colour [] colours): void
  • getLabels(): Label []
  • getColours(): Colour []

End of day report

After all servers are finished a report should be generated (presumably similar to the report from stage 1)

Cross-platform formatting

As we may all be working on different platforms and using different IDEs, we may want to set up some system of cross platform compatibility.

One such system is to all use EditorConfig. There's a plugin for VS Code and Eclipse which I know some of us are using both of.

Implement the Food class

Inherits from #1
Uses #14

  • dietaryClasses: DietaryClass []
  • Food(DietaryClass [] dietaryClasses): void
  • getDietaryClasses(): DietaryClass []

Implement the OrderBeverage class

Uses #14

  • size: Size
  • isHot: bool
  • milk: Milk
  • OrderBeverage(MenuItem menuItem, Size size, bool isHot, Milk milk): void
  • getSize(): Size
  • isHot(): boolean
  • getMilk(): Milk
  • getPrice(): BigDecimal

Improve GUI layout

The current layout is perfectly functional, but could be improved using a GridBagLayout which allows use of a grid with varied column/row dimensions (e.g. so the tables can take more horizontal space than the controls to the right). However, it is more complex to set up as desired than the currently used GridLayout.

I originally tried to do this but found that elements weren't expanding/contracting as the window was resized.

Implement the CustomerGUI class

Will be using a JList to show menu items, with buttons to toggle between filters for each item category. Controls at the side to set item properties when adding to an order. Current basket shown below, upon submission order is converted to separate Order instances as per the project specification (one for each item).

This is quite a big issue and we may want to open sub-tasks as issues linked to this for better incremental tracking.

Discount will also be applied to the basket upon submission.

  • menu: MenuTableModel
  • processed: OrderList Handled by #30
  • basket: OrderTabelModel
  • CustomerGUI(MenuTableModel menu, OrderList processed, OrderTableModel basket): void
  • addToBasket(Order o): void
  • applyDiscount(): BigDecimal Handled by #30
  • writeToFile(String fileName, String input) Handled by #30 or similar (need to finalize plan)
  • checkout(): boolean
  • setUpMenu(): void
  • setUpCheckout(): void

Make OrderList polymorphic

Currently our OrderList is hardcoded to use a LinkedList for storage. This makes sense for the historical list which is primarily having orders appended to it. However, we're also using an OrderBasket (subclass of OrderList) for the UI's basket storage which means the UI table is more often accessing the values to display them. Here it would make more sense to use an ArrayList.

The idea is to have the constructors accept any List as a parameter and use that for the storage. This way, the different instances can benefit from different List types as decided when they are instantiated.

Implement Staff Threads

  • server will take orders from the shared object and
  • kitchen staff will take orders from the shared object and sleep

Implement the Order class

One order per #15

  • time: LocalDateTime
  • customerID: String
  • itemDetails: OrderItem
  • pricePaid: BigDecimal
  • Order(LocalDateTime time, String customerID, OrderItem itemDetails, BigDecimal, pricePaid): void
  • getTime(): LocalDateTime
  • getCustomerID(): String
  • getItemDetails(): OrderItem
  • getPricePaid(): BigDecimal

Implement the OrderTableModel class

  • orderList: OrderList
  • OrderTableModel(OrderList orderList): void
  • getColumnName(int column): String
  • getColumnClass(int column): Class<?>
  • getRowCount(): int
  • getColumnCount(): int
  • getValueAt(int rowIndex, int columnIndex): Object

Implement the OrderMerchandise class

Uses #14

  • label: Label
  • colour: Colour
  • OrderMerchandise(MenuItem menuItem, Label label, Colour colour): void
  • getLabel(): Label
  • getColour(): Colour
  • getPrice(): BigDecimal

Remember price will need to get basePrice from MenuItem and add any additional cost for features

Set up project skeleton

Need to get the initial project skeleton here on main branch for us to start our workflow on.

As we want to use JUnit for unit testing I may need to investigate build tools such as Maven for an IDE agnostic setup.

Implement Queue class

Shared object of the application.
Will have a list that's updated with incoming orders from the producer class (Order class). Elements will be removed from the list by the consumer threads (Server class).

  • booleans empty/ done
  • LinkedList
  • getCustomerOrder
  • addOrder
  • getDone()
  • setDone()
  • displayQueue()

Adapt order data to fit stage 2 context

List of input orders no longer represents orders that are in the past, but orders that will happen during the simulation (in future).

We should take out the data that isn't known yet (price paid, timestamp) and generate it at runtime (apply discount, etc.)

Implement Enums

  • Size: S, M, L
  • Milk: None, Regular, Soy, Oat
  • DietaryClass: Vegan, Vegetarian, Gluten Free, Diary Free
  • Label: Coffee, Tea
  • Colour: White, Red, Green

Keep in mind there will need to be a way of tracking the effect on price for some of these (Size, Colour, possibly Milk). See the lecture notes on enums 😃

Implement the Menu class

Stores instances of #1

  • menu: HashMap
  • Menu(): void
  • add(MenuItem m): void
  • readFile(String fileName): void
  • processLine(String line): void
  • getReport(): String
  • getKey(String key): MenuItem

Implement the MenuTableModel class

  • menu: Menu
  • MenuTableModel(Menu menu): void
  • getColumnName(int column): String
  • getColumnClass(int column): Class<?>
  • getRowCount(): int
  • getColumnCount(): int
  • getValueAt(int rowIndex, int columnIndex): Object

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.