• Embed Doc
  • Readcast
  • Collections
  • 1
    CommentGo Back
Download
 
Exercise 1: Using Arguments and Return Values
The objective of this exercise is to write a class with a method that invokes a workermethod in another class.
Task 1 – Writing a Class That Uses Arguments andReturn Values
In this task, you write a test class that adds multiple
Shirt
objects to an
Order
objectand displays a total current amount, in dollars, for the order. Follow these steps to writeyour test class:1. Go to the
methods
directory.2. Write a class called
OrderTest
containing a
main
method.3. In the
main
method:a. 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 viewthese files and familiarize yourself with them.b. Set the
price
for the
Shirt
object to 14.00.c. Invoke the
addShirt
method to add the shirt to the order. Thedocumentation for the
addShirt
method is as follows:
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.d. Display the return order amount. For example:
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.
 
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...