As usual, create a directory to hold today's activities:
$ mkdir ~/cs170/labs/lab8 $ cd ~/cs170/labs/lab8
Monday's activity
. So today in lecture I'm going to cover what I was looking for out of the activity given to you on Monday. The code will be made available to you below. You still need to pay attention to the process, so you will be better able to replicate it on your activities today.One thing that is very common in programming is creating programs that solve problems for other industries. Usually,
. You may be concerned about different things than your colleagues, which shapes your view of the actual problem space. One way around that is to make sure you design your programs well from the start, which I think is the issue we've been hitting most often. So, for the following activity please make sure you design your program very well.You have a friend that works at the post office. Their software crashes incessantly, which is a problem since they have to process thousands of packages. And with Valentine's day just around the corner, they are looking at losing a lot of money. So he wants your help to create a temporary program to help him out.
Your program should be capable of reading in package information from the user. Each package is going to be described by their dimensions (length, width, and height). It will also have an associated weight and tracking number.
Your program should keep track of all of the packages that are currently being processed. The user managing the program should be able to mark a package as being delivered, which means removing the package from being tracked.
postoffice_tracker = Tracker() postoffice_tracker.add_package(7, 2, 7, 14, "01001") postoffice_tracker.add_package(4, 4, 4, 3, "01110") print(postoffice_tracker) #Prints: # Package 1: 7 x 2 x 7, 14 oz, Tracking: 01001 # Package 2: 4 x 4 x 4, 3 oz, Tracking: 01111 postoffice_tracker.remove_package("01001") print(postoffice_tracker) #Prints: # Package 1: 4 x 4 x 4, 3 oz, Tracking: 01111
As you might have guessed, you probably want at least 2
classes: Package
and Tracker
.
Package
needs attributes for the dimensions of
the package, as well as its weight and tracking number. You
will probably want to define the __str__
method
for this object, but likely nothing else.
Tracking
needs one attribute, a list of packages.
It needs methods add_package
and remove_package
.
The above program does not factor in the cost of the package that is being shipped. I guess your friend is going to have to use a calculator and an table to determine how much a shipment will cost. Unless...I bet you could add that computation to one of your classes!
For the sake of ease of use, let's assume that a package costs $0.49 per ounce to be mailed.
When you have finished, create a tar file of your lab8
directory. To create a tar file, execute the following commands:
cd ~/cs170/labs tar czvf lab8.tgz lab8/
To submit your activity, go to inquire.roanoke.edu. You should
see an available assignment called Lab Assignment 8
.
Make sure you include a header listing the authors of the file.