Comp 152 Project 2:
Objects
Due: Tuesday
Oct 5th at 11:59pm
now Wed Oct 6th at 11:59pm
Summary:
In this project we will begin to build an object oriented program. We
will build on this program in later labs.
Details:
Use the UML class diagram below and write the four classes involved.
Descriptions of what each method does are found below the diagram
You may add any private 'helper functions' that
you want to add to this diagram, you just have to have these methods
which do what is listed below, but if you break them down and call
private methods to make your design cleaner that is great.
- Store Class:
- main, this is the main method in the program, it should create a
store object (Call the store constructor) and then call runStore on
the store object.
- Store constuctor: this method should
- create the instance variables
- open a file called Customers.txt which will be a comma separated
file of customers, read it in and use each line to create a Customer
object and then add it to the Customers ArrayList
- RunStore should
- start a command line 'menu' in a while true loop
- the menu should offer the following choices
- add customer (call the addCustomer method)
- select customer (call the selectCustomer method and then use
the returned Customer object as a parameter and call the
manageCustomer method
- quit (end the program)
- Select Customer should
- allow the user to select a customer
- return that customer as a return value
- Manage customer should
- start a command line 'menu' in a while true loop
- the menu should offer the following choices
- add address (create an address object from values provided by
the user and then call addAddress on the currently selected
customer
- make order (create a new order for the current customer by
calling makeOrder [let the user choose the shipping address from
the list of addresses for the current customer] )
- makeOrder (create a new Order object and add the new order to the
Orders ArrayList)
- the toString method should return an attractive string
representation of the Customer (using the instance variables formatted
into an easy to read string.
- Customer Class:
- Customer Constructor must take a string as a parameter and use that
string to initialize the Name instance variable. It should also assign
a unique customerID to its customerID instance variable (use the
static class variable technique that we talked about in class). Also
create the Addresses instance variable here
- getName is an accessor which returns the value of the name instance
variable
- addAddress should take the address passed as a parameter and add it
to the addresses list.
- Order Class:
- Order Constructor should take its two parameters and use them to
initialize the two instance variables.
- getDestination should return a string representation of the
destination ShippingAddress variable
- getOrderer should get a string representation of the customer who
made the order.
- ShippingAddress class
- the toString method should return an attractive string
representation of the address (using the instance variables formatted
into an easy to read string.
Have fun and learn a lot. This will take
some time, but each piece is fairly straightforward.
Additional Requirements:
- create a new project in intellij (don't
submit a bunch of notes and other extraneous files as part of the
project)
- be sure to include your name in the
project name somewhere.
- Comment your code well enough that I know you know what you wrote.
- Start with one of the classes, and build it. Add it to git, and share
on github early and often I will look at the commit history. I am
looking for evidence that you committed a lot a small amount of credit
will be reserved for this
Submission:
submit by sharing your project with me on github like last time.