A3 ◦ Customer Orders

The following assignment is due Friday, September 21 at 5pm and will be graded immediately afterwards.

  • Please remember, tutors and other students are not allowed to view your work and you are not allowed to view other student’s work.
  • Students that submit code that does not compile will receive no credit for this assignment.
  • Programming takes a lot of time.  Please start immediately.
  • I have set up RSS feeds to monitor your commits.  Commit often and early. Use meaningful commit messages.  If you want me to look at your code, include @erimcg in your commit message.

Create the following classes:


  • Include the following fields.
    • name (String)
    • cost (double)
  • Include a constructor that initializes all of the fields.
  • Include getter methods.


  • Include the following fields.
    • item (Item)
    • quantity (int)
  • Include a constructor that has the following parameters: name (String), item cost (double), and quantity (int).
  • Include getter methods.


  • Include the following fields:
    • orderLines (OrderLine[10]) which holds an Array of no more than 10 OrderLine objects.
    • count (int) which is initialized to zero and holds the number of OrderLine objects in the array.
  • No constructor is included.
  • Include a method name addItem that takes as a parameter an OrderLine object and inserts it into the orderLines array.
  • Include a method named printOrder that iterates over the orderLines array and for each OrderLine object prints on a separate line the item name, item cost, and quantity.


  • The driver does the following:
    • Creates a new Order object.
    • In a continuous loop:
      • Displays the following menu:
        1. Add Item
        2. Print Order
        3. Exit
      • Asks the user to enter a menu number.
      • Reads the menu number.
      • If the user enters 1, the program asks the user for an item name, item cost, and quantity and retrieves the data.  It then creates a new OrderLine object with the data and passes it to the Order object’s addItem method.
      • If the user enters 2, the program calls the Order object’s printOrder method.