Exercise 1: Using Arguments and Return Values

The objective of this exercise is to write a class with a method that invokes a worker method in another class

Task - Writing a Class That Uses Arguments and Return Values

In this task, you write a test class that adds multiple Shirt objects to an Order object and displays a total current amount, in dollars, for the order. Follow these steps to write your test class:

  1. Go to the methods directory.
  2. Write a class called OrderTest containing a main method.
  3. In the main method:
    1. Create object references to objects of type Order and of type Shirt. The Order class ( Order.java ) and the Shirt class ( Shirt.java ) are provided in the exercise directory for this module. You should view these files and familiarize yourself with them.
    2. Set the prices for the Shirt object to 14.00
    3. Invoke the addShirt method to add the shirt to the order. The documentation for the addShirt method is as follows:
    4. public double addShirt (Shirt s)

      Adds a shirt to a list of shirts in an order.

      Parameters:

      s- An object reference to a shirt object

      Returns:

      A total current amount for the order.

    5. Display the return order amount. For example:
    6. Total amount for the order is: 14.00

  4. Create additional Shirt objects, and add them to your order. Does the total amount for the order increase accordingly?
  5. Compile and execute your program