Inventory Project
Read the assignment before you start. The order in which aspects are described does not necessarily indicate the order in which you should write the code.
It is up to you to use the concepts we have covered to design the
classes and methods that will go into your program; your grade will be
based on how well you do this. I would like to be able to give you credit for:
classes, variables (types, instance, local), methods (parameters, return), conditionals (if, else), loops (while, for), and arrays.
Most of the credit for this programming project will be given for
making good use of the programming ideas we've covered. A program that runs with
nice output
but does not make use of these ideas will get minimal credit. (i.e. if you've
got one big main and that's all, you're doing something wrong). Assume you
are writing a program that will later be updated and maintained (look at the EC
for examples of the kind of changes your code should make it easy to do).
Correct projects will only use concepts and constructs we have covered in class.
Feel free to reuse code you have already written or example code that has been
given, but be sure to remove portions
unrelated to the current assignment, and to update variable names, method names,
etc.
Readability matters.
Use comments to clarify what your code is trying to do.
If code does not work; partial credit will only be given if comments
explain what it was trying to do.
Programming Assignment
Our program is for a store with media items, and customers that can buy, own,
and use these items.
A media item has a name and a price. Some items are currently on sale,
which means the user can buy them at 10% lower than the actual price.
Users can "use" their media items; when basic media items are used, just
print a message including the name, saying that it is in use.
The store has a list of all media items being sold and a list of customers.
Each customer has a username, a balance, and a
list of the media they have bought (which starts off empty, but they
should be able to buy at least 10).
The store has a list of at least 15
different media items to sell (some on sale), and a list of at least five customers [NOTE: Put
the usernames of your customers in a comment at the top of your main class so I can
find them easily when testing.
Your life will be easier if all your customers have one word (no spaces) names.]
When the program starts, a customer can log in by typing in
their username, or quit the program. If they type in a wrong name (not an existing customer), they're
just back to the option to log in or quit.
A customer who is logged in is shown a main menu where they can
browse the media they already own, shop for more,
add to their current balance, or log out. Once they log out we are back to letting someone
else log in (or quit).
You do not have to worry about users entering completely invalid data (like
a letter when you asked for a number). However, when asking how much to add to their balance,
make them keep trying until they give a sensible (positive) answer.
When customers shop for new items, they are shown a list of all items in
the store and can choose one from the list (probably by number).
If they choose a valid number, check if they have enough money in their balance for the price and if so
add the chosen item to their list and deduct the price, otherwise tell them what went wrong.
(You do not have
to remove the item they bought from the store, this is digital media and
they just get a copy)
When customers browse their own media, they are shown all the items
they own, and can choose from the list an item to use (probably by number). If they
choose a valid number, use that media, otherwise tell them what went wrong.
Whenever one customer logs out, we should be back at letting a customer
log in or quit the program. Within one run of the program, a
customer should be able to log in, buy new media, and log out, then another customer can log in
buy and log out, and then the first customer can log back
in again later and see the media they bought earlier when they browse what they own.
hints: Firstempty. Put behaviors that a class does or that are all about a class' data in that class.
Breaking up tasks into little methods make it easier to write and test. The main method
is mostly in charge of dealing with the user: it calls methods to get things done
-- make good use of parameters and return values to get data in and out of methods.
Instance vars are expensive and only used for important characteristics of a class (local variables are cheap).
Instance vars always mean we also have...
[EC+10] Instead of you just setting up some items to be on sale, each time a
new user logs in, the program randomly chooses three items to be on sale.
When they log out, set everything in the store back to not being on sale.
When randomly choosing, make sure these are three different items.
[EC+10]
Add a third option at the start of the program, instead of logging in or quitting they can create a
new customer, which gets added to the store's list. They cannot have the same username as an existing
customer.
[EC+20] (requires inheritance/polymorphism) There are three more specific types of media: books, movies, and games.
In addition to what all media has, books also have an author and number of pages,
movies have a running time, and games have a version number. When a book is used, tell the user
the book is being opened and how many pages, when a movie is used, tell the user
the video is playing and how many minutes long it is, when a game is
played, tell them the game is starting and tell the user the
version. (You only need to display messages to say that these
things are happening; you do not need to worry about any actual
media.). Include some books, movies, and games in the list of those that can be bought in the store.
(hint: this should require very little change to how the store part of your program works from
the regular assignment, just creating media of different types)