1 / 14

Assignment 2

Assignment 2. Salim Malakouti. Problem Definition?. Restaurant Owner Sells only potatoes Keep the profit Maximized. Minimize potatoes wasted + Minimize effort. Goal. In other words you are trying to keep the potatoes sorted with minimum effort possible. What is the problem?.

taurus
Download Presentation

Assignment 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Assignment 2 Salim Malakouti

  2. Problem Definition? • Restaurant Owner • Sells only potatoes • Keep the profit Maximized Minimize potatoes wasted + Minimize effort

  3. Goal • In other words you are trying to keep the potatoes sorted with minimum effort possible

  4. What is the problem? • You are using a Stack(box) to keep the potatoes • You can use a separate temporary box(Stack) • You are keeping everything in the truck in a stack • You can’t take anything back to the truck. • You need your employee to carry boxes between these boxes or the truck.

  5. Code? • Use: take n from top of the main stack • Skip: Here you move on to the next day. So you should throw out any boxes that are expired + a message for each. • Report • A report for the latest delivery • A report for overall deliveries • Report include: • Number of boxes • Total cost • Cost of moving around • Quit

  6. Display • Display the content of the current box • Different methods • Alter toString method

  7. Receive *** • You receive a stack of boxes from file with the following format: <company>:<date>:<cost> • Example: receive 6 Spud Heaven:3:4.5 Potato Pot:4:5.0 Tuber Town:3:4.0 Perry's Potatoes:9:5.5 Potato Pot:10:5.0 SpudsRUs:3:4.0 • Hard Part: Giving an algorithm for itusingpops and pushes.

  8. Good Question? • Can we sort them in the file? NO • If you want to sort them you have to use the stacks that you have.

  9. A simple example? 1 3 4 3 5 4 1 8 5 10 9 8 9 10

  10. Important • You won’t have any interactive interface? • So how inputs are given? • Through input files.

  11. Sample Input File • display • report • use • 5 • receive • 5 • Fiveth:5:5.0 • Fourth:4:5.0 • Threeth:3:5.0 • Twoth:2:5.0 • Oneth:1:5.0 • display • report • quit • report • display • use • 8 • skip • receive • 4 • Bogus:0:100.0 • Weasel:0:150.0 • Squat:0:125.0 • Nada:0:100.0 • report • receive • 5 • Oneth:1:5.0 • Twoth:2:5.0 • Threeth:3:5.0 • Fourth:4:5.0 • Fiveth:5:5.0

  12. How to read the file? • You need to parse it? Ideas?

  13. Split function • String test = “1,2,3,4,5”; • String[] numbers = test.split(“,”); • System.out.print(numbers.length); OUT: 4 [“1”,”2”,”3”,”4”]

More Related