Wj 1103a Module 3 Exercise1

  • Uploaded by: Rajani Ramsagar
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Wj 1103a Module 3 Exercise1 as PDF for free.

More details

  • Words: 244
  • Pages: 2
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 1 – 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: 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 view these 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. The documentation 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.

Related Documents


More Documents from "Rajani Ramsagar"