Conveniently, the web server shares a filesystem with GL, so you can use the Unix/Linux
file copy command,
cp, to copy the files from the web directory on GL to your
project directory on GL, without downloading them from the web page at all.
cp /afs/umbc.edu/users/s/m/smatus1/pub/www/331/java1/*.java /wherever/331/java1/
cp /afs/umbc.edu/users/s/m/smatus1/pub/www/331/java1/* /wherever/331/java1/
The first argument to cp is the path to the source file or files. Note that it ends with a *, meaning that it should copy all the files it finds there. You will end up with a couple files you don't need, but you should also end up with all the .java, .jar. and .sh files. [Oops: previous version ended with *.java, meaning you only got the .java files.]
If you are doing the coding on your local machine, and need to upload the files to GL, you
have a couple choices. If you are using Linux or Mac OS X, you can open Terminal and use
which is a version of
cp that can copy files securely over a network connection.
The command will look something like
scp -r /Users/steve/workspace/java1/src firstname.lastname@example.org:~smatus1/331/java1/
-r flag tells scp to recursively copy the contents of all directories. The first argument is the
location of your project directory on your local machine. The second argument is the address to copy
the files to. It starts with a username (
smatus1, but use yours), then an
then the name of the remote machine (
gl.umbc.edu), then a
:, then the path
to copy the files to (
~smatus1 is a shorthand
meaning "the home directory of the user smatus1" (but obviously use your own, not mine).
If you are using Windows, I recommend acquiring and learning to use WinSCP.
cmsc331_smatus1, and this project is
To submit this project:
submit cmsc331_smatus1 java1 *.java
I only want the Java files, not the class files, or the jars that you got from me. (But I do want your copies of the Java files that I provided.)
To check that your files all got submitted:
submitls cmsc331_smatus1 java1
The result should look similar to
total 16 drwx------ 2 smatus1 rpc 2048 Mar 2 15:10 . drwx------ 46 smatus1 rpc 2048 Mar 2 14:56 .. -rw------- 1 smatus1 rpc 135 Mar 2 14:34 Applesauce.java -rw------- 1 smatus1 rpc 340 Mar 2 14:34 ApplesauceCoupon.java -rw------- 1 smatus1 rpc 637 Mar 2 14:34 Cart.java -rw------- 1 smatus1 rpc 2468 Mar 2 14:34 CartTest.java -rw------- 1 smatus1 rpc 96 Mar 2 14:34 Chicken.java -rw------- 1 smatus1 rpc 195 Mar 2 14:34 Coupon.java -rw------- 1 smatus1 rpc 53 Mar 2 14:34 Item.java -rw------- 1 smatus1 rpc 48 Mar 2 14:34 Meat.java -rw------- 1 smatus1 rpc 200 Mar 2 14:34 MeatCoupon.java -rwxr-xr-x 1 smatus1 rpc 180 Mar 2 15:11 MyTests.java
General instructions for using
submit can be found at http://www.gl.umbc.edu/submit/.
You are provided the file
CartTest.java, containing several unit tests.
setenv CLASSPATH junit.jar:hamcrest-core.jar:.
java org.junit.runner.JUnitCore SimpleTest
JUnit version 4.12 . Time: 0.004 OK (1 test)
CartTest.java:11: error: cannot find symbol Item item = new Applesauce(); ^ symbol: class Applesauce location: class CartTest
CartTest.java:12: error: cannot find symbol cart.add(item); ^ symbol: method add(Item) location: variable cart of type Cart
Applesauce.javayet, and you haven't written the
Here is a summary of the expected functionality (which you must implement):
Cartmust provide the methods:
add(Item item), which adds an
Itemto the cart's internal list of items. (I gave you the code that creates the list.)
add(Coupon coupon), which adds a
Couponto its internal list of coupons. (You'll have to create that yourself.)
getItemCount(), which tells you how many items the cart contains. Hint: use List methods.
getTotal(), which tells you the total cost of the items in the cart, after applying coupons.
Itemis an interface with one method:
public double getPrice()returns the price of this kind of item.
Couponis an interface with one method:
public double getNewPrice(Item item)
Couponmust implement this method. The method works as follows:
Applesauceis a kind of
Meatis a kind of
Item. It cannot be instantiated directly.
Chickenis a kind of
ApplesauceCouponis a kind of
MeatCouponis a kind of
One tip: Fix the first compiler error first. Often, later errors are duplicates, or are caused by earlier errors.
Reminder: you run a unit test (or, rather, a class full of unit tests) like so:
java org.junit.runner.JUnitCore CartTest
CartTest.javashould succeed as written, with the exception of
testTotal1, which you should fix, and
applesauceIsNotMeat3(), which you can ignore.
Chicken is $6.99. Applesauce is $3.80.
Meatwhose price is measured by the pound (or kilogram).
Couponthat would interfere with each other. Ensure that only one is applied.
Couponwhose acceptance criterion is not a simple
instanceof. Figure out the best way to implement this without breaking abstraction -- it is okay for coupons to "know" about different kinds of items, but items should never "know" about coupons.
submitscript, as described at the top of this page.
The project is due by midnight on Friday, October 2 (as in the moment between Friday and Saturday).