Table of Contents

This is not a current assignment. If you are currently enrolled in SE1010, do not do this assignment expecting to receive credit for it.

Lab 6: Class Creation

Summary and Assignment

You will implement a class given a description of its behavior, a partial class diagram (showing only required public methods), sample code that uses the class, and a sequence diagram that illustrates key elements of this sample code.

Details

Your job is to complete a program that will allow a ground shipping company to do various calculations regarding shipping packages on its trucks. These calculations take into account the size and weight of the packages, the fee to ship each package (which is a function of the package's size and weight), and the capacity (in volume and weight) of each truck.

The design has been completed for you. See the class diagram for details. Another software developer has already completed a Truck class and a ShippingCalculator class that contains various static methods for testing the other classes. Your job is to implement the Package class. The class diagram shows which public methods you must implement. If needed you may implement other methods, but they must be private. Also, you will need to add some attributes, but they must also be private.

You should begin by reviewing the Truck.java source code and its documentation. Then, review the ShippingCalculator.java source code, its documentation, and the sequence diagram to see how the pieces fit together.

Creating the Project

Create an Eclipse project by following these steps:

  1. Download the file se1010lab6.zip and save it in a convenient location on your computer. (Depending on your browser, you may need to do a right click to save the file.) DO NOT save the file inside your Eclipse workspace.
  2. From the File menu, select New⇒Java Project.
  3. In the Project Name field, enter “Lab6” or a project name of your choice.
  4. Make sure that the correct options are selected (see creatingaproject).
  5. Click on Finish to create the project.
  6. Right click on the project name (e.g., “Lab6”) in the Package Explorer, and select Import… from the pop-up menu.
  7. In the Import dialog box, select General⇒Archive File and then click on Next.
  8. In the From archive file: field, browse to the se1010lab6.zip file you previously downloaded and then click on Finish.
  9. Go to the Package Explorer and open the src view.
  10. Right-click on the “edu.msoe.se1010.shipping” package and select New | Class.
  11. Enter “Package” as the class name and select Finish to create and begin editing the class. You will have numerous errors at this point as the imported code references methods in the Package class that you have not yet written.

Shipping Fee Algorithm

Notes

Test Cases

Length (in) Width (in) Height (in) Weight (lb) Fee
12 14 16 10 $38.89
3 4 6 3 $9.38
72 10 6 15 $62.50
20 20 40 1,000,000 $1,041,666.67
5,000 20 15 75 $21,701.39

Sample Output

Upon implementing Package correctly, your output in the Console tab will look similar to the following. Since the second test uses a random number generator, your numbers should be similar, but will not match exactly. Note: achieving output that looks like this does not guarantee that you have implemented Package correctly.

10# box costs $38.89 to ship.
box of skis costs $62.50 to ship.
really, really dense package costs $1,041,666.67 to ship.
really, really long package costs $21,701.39 to ship.
10# box added
box of skis added
really, really dense package didn't fit
really, really long package added

A total of 4070 trucks were needed to contain 1000000 random packages that had a gross revenue of $77,198,100.37.