Anda di halaman 1dari 3

CS152 Spring 2013 Project#1 Packets

Packet objects have unique ID number, state abreviation for their destination, and weight in pounds with 2 decimals. Class Packet describs packets and has variables idNumber, state, and weight of type int, String and double, respectively. In addition, it has the following methods isHeavy that returns true when packet is above 12 pounds, and false otherwise. isLight that returns true when packet is below 7 pounds, and false otherwise. toString returns String which is one line representation of Packet objects.

Create an input file called allPackets.txt with the following 7 lines: 1001 7.37 CA 1002 5.17 CT 1003 11.35 NY 1004 20.17 MA 1005 9.99 FL 1006 14.91 VT 1007 4.97 TX Each line in the allPackets.txt file has information about one packet object. Class Packages has shipment and totalWeight variables. Variable called shipment contains the collection of all packets. Variable shipment is of ArrayList type. All objects in the ArrayList shipment are of Packet type. Variable totalWeight is initialized to 0.0. Totalweight specifies the total weight of all packets. The constructor assigns variables shipment and totalWeight. Use input file called allPackets.txt to read input data from the file. Each line in the file has data about one packet object. The data from each line should be assigned to a Packet type object first and then that Packet type object should be added to the collection. Class Packages should have the following methods: toString which returns String representation about entire collection of packets with one packet object specified per line. displayLightPackages which displays all packets that are light. displayHeavyPackages which displays all packets that are heavy . displayOtherPackages which displays all packets that are neither light nor heavy. displayTotalWeight displays total weight of all packets with full sentence. (Use simplest code) displayAverageWeight displays average weight (with two decimals) of all packets. Use full sentence. (Use simplest code)

Your application should also have class TestPackages with only main method in it, in addition to classes Packages.

Packet and

SUBMIT: BlueJ Design Code for each of the three classes. Program run documented. Extra Credit

POSSIBLE POINTS 1 points 8 points 1 point 1 point

STUDENT GRADE

EXTRA CREDIT (1 point)


Add method stateLocation to Packet class. Method returns String "Local" if state is one of CT, MA, ME, VT, NH, RI, NY, and returns String "NonLocal" for all other states. Add the following two methods to Package class: displayLocalPackets which displays one empty line, then title "LOCAL PACKETS", and next it displays all local packets (one per line). displayNonLocalPackets which displays (in analogous way) all packets that are not local. Input file called packetData.txt 1001 7.37 CA 1002 5.17 CT 1003 11.35 NY 1004 20.17 MA 1005 9.99 FL 1006 14.91 VT 1007 4.97 TX

PROGRAM RUN outline: ALL PACKETS Display all packets All HEAVY PACKETS Display all heavy packets All LIGHT PACKETS Display all light packets All REGULAR PACKETS Display all regular packets (neither light nor heavy) Total weight of all packets is XXXX. Average weight of all packets is XXXX. EXTRA CREDIT - LOCAL PACKETS Display all local packets EXTRA CREDIT - NONLOCAL PACKETS Display all packets that are not local

Project should be submitted via Blackboard Vista assignment tool. Do not forget to press submit button at the end. A PDF file that you submit should be named P1YourLastName.pdf. Include the following in the upper left corner of your project file.
STUDENT NAME: DATE: Project#1 Instructor: Irena Pevac Section: (specify only your own section) either CS152 -01 CRN 40978 or Semester: Spring 2013 (Class meeting days for your section) either MW or TR

CS152-70

CRN 40979

SUBMITTED: BlueJ Design Code for each of the three classes. Program run documented in a Word file. Extra Credit

POSSIBLE POINTS 1 points 8 points 1 point 1 point

STUDENT GRADE

SUBMIT one PDF document: 1) Include the picture of the design from BlueJ. Resize the BlueJ design window to display all the classes and relationship lines with minimal window size. 2) Include the code for each class. The code for each class should be pasted into a separate table that only has one cell. Font size should be 12. 3) Include the picture(s) of the program run ( for all different possibilities as suitable). HOW TO COPY THE CODEfrom BlueJ into Word document: Copy the code for each class from BlueJ into separate table in the word document. Each time do the following: highlight entire code in the BlueJ code window and press COPY. Move to Word document and insert table od size 1x1. Move cursor into the cell in the table. Set paragraph to single line spacing and 0 space before and 0 space after the paragraph. Press keys CTRL and v together to paste the copy of the code into the table. HOW TO COPY THE PICTURE OF ANY WINDOW into Word document: When your program is running the picture of output window from BlueJ should be captured. To put the copy of the picture of entire window press keys ALT and Print Scrn together. Move to the Word document and press CTRL and v keys together to paste the picture. If the output from the program is too long save the outcome to an output file from BlueJ output window and paste the picture of that file.

Anda mungkin juga menyukai