Bargain Bill's Discount Autos

Bargain Bill's Discount Autos

Due September 11th by midnight

Objectives

This assignment should let you try your hand at python scripting, as well as simple text input and output. You should also get some practice using a few of Python's built-in data structures, modules and functions, which are often more than enough for small problems. Do not define any new classes in your program.

Description

Last year, Bargain Bill, owner of Bargain Bill's Discount Autos, purchased a computer program to help him monitor his inventory (that box of 3" × 5" index cards just wasn't doing the trick). Since that time, Bill has acquired a few more employees and opened two more locations with computers using several different operating systems, and now needs one inventory application to run in all locations. You decide to flex your Python skills, and tell Bill, “I'll have it for you in two days.” Bill, who has no idea that it will probably take you less than an hour, smiles with approval and does that annoying thing he does where he points his finger at you like it's a gun and makes shooting noises. That's Bargain Bill for you…


Below is an example trace of how the program should work. User keystrokes are in red, program output is in black. An empty line indicates that the user just hit Enter without making any other keystrokes (users do weird things sometimes and your program must handle them gracefully).


mymachine:~/mypythonfiles> python cars.py

---------------------------------------------------
Bargain Bill's Inventory Program
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: w
Enter one of the letters listed in paren.
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: l
---------------------------------------------------
TOTAL VALUE: $0.00
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: a
Year: 1971
Make: Chevy
Model: Impala
Color: green
VIN: Julian's ride
Price: 10000
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: l
---------------------------------------------------
1971 Chevy Impala, green (Julian's ride): $10000.00
TOTAL VALUE: $10000.00
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: a
Year: 1
Enter a year between 1900 and 2010
Year: gfd
Enter a year between 1900 and 2010
Year: 2006
Make:
Enter the car's make.
Make: Ford
Model: Mustang
Color: silver
VIN: fh87g3hfh758
Price: 12499.99
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: l
---------------------------------------------------
1971 Chevy Impala, green (Julian's ride): $10000.00
2006 Ford Mustang, silver (fh87g3hfh758): $12499.99
TOTAL VALUE: $22499.99
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: a
Year: 1969
Make: Dodge
Model: Charger
Color: orange
VIN: hfv738fhh65
Price: -12
Enter a dollar amount as a number
Price: fifty
Enter a dollar amount as a number
Price: 25000
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: l
---------------------------------------------------
1969 Dodge Charger, orange (hfv738fhh65): $25000.00
1971 Chevy Impala, green (Julian's ride): $10000.00
2006 Ford Mustang, silver (fh87g3hfh758): $12499.99
TOTAL VALUE: $47499.99
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: s
---------------------------------------------------
1971 Chevy Impala, green (Julian's ride): $10000.00
2006 Ford Mustang, silver (fh87g3hfh758): $12499.99
1969 Dodge Charger, orange (hfv738fhh65): $25000.00
TOTAL VALUE: $47499.99
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: d
---------------------------------------------------
(1) 1971 Chevy Impala, green (Julian's ride): $10000.00
(2) 2006 Ford Mustang, silver (fh87g3hfh758): $12499.99
(3) 1969 Dodge Charger, orange (hfv738fhh65): $25000.00
(Hit Enter to return to main menu.)
Enter car to delete (1-3):
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: d
---------------------------------------------------
(1) 1971 Chevy Impala, green (Julian's ride): $10000.00
(2) 2006 Ford Mustang, silver (fh87g3hfh758): $12499.99
(3) 1969 Dodge Charger, orange (hfv738fhh65): $25000.00
(Hit Enter to return to main menu.)
Enter car to delete (1-3): w
Enter a number between 1 and 3
(Hit Enter to return to main menu.)
Enter car to delete (1-3): 2
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: l
---------------------------------------------------
1969 Dodge Charger, orange (hfv738fhh65): $25000.00
1971 Chevy Impala, green (Julian's ride): $10000.00
TOTAL VALUE: $35000.00
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: a
Year: 1969
Make: Dodge
Model: Charger
Color: red
VIN: hg85945g65
Price: 25000
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: l
---------------------------------------------------
1969 Dodge Charger, orange (hfv738fhh65): $25000.00
1969 Dodge Charger, red (hg85945g65): $25000.00
1971 Chevy Impala, green (Julian's ride): $10000.00
TOTAL VALUE: $60000.00
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: q
Exiting Inventory Program.
Save Changes? y
Changes Saved.
Goodbye.

mymachine:~/mypythonfiles> python cars.py

---------------------------------------------------
Bargain Bill's Inventory Program
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: s
---------------------------------------------------
1971 Chevy Impala, green (Julian's ride): $10000.00
1969 Dodge Charger, orange (hfv738fhh65): $25000.00
1969 Dodge Charger, red (hg85945g65): $25000.00
TOTAL VALUE: $60000.00
---------------------------------------------------
(a)dd a new car
(d)elete a car
(l)ist all cars
(s)ort by price and list
(q)uit
---------------------------------------------------
Enter your choice: q
Exiting Inventory Program.
Save Changes? n
Goodbye.

Put your program in a file called cars.py. Advice: Keep an eye on the class discussion board for helpful hints on how to do this assignment!

Grading Criteria

Your program will be graded on correctness, robustness, style, and elegance. You should attempt to make your code easy to read. Anything that is not immediately obvious should be thoroughly commented. Your program interface does not have to match the example above exactly, but should be similar in feel.


Your program should check for bad input and respond appropriately. Do not use numbers for your menus unless necessary (i.e. the delete car option). Notice that the (l) option sorts by year then make then model etc, but the (s) option sorts by price then year then make then model etc. Also notice that on exiting the program the user may optionally save the list of cars to a file that will be automatically re-opened the next time the program is run.

Submission Checklist

  • cars.py