Homework Assignments:


The abbreviation DWH used in the homework descriptions refers to the book Introduction to Java and Software Design by Nell Dale, Chip Weems, and Mark Headington.  The abbreviation LCJ refers to the book A Laboratory Course in Java by Nell Dale.


You must turn in a printed and/or written version of your homework assignment each week.  Unless otherwise specified, homework will be due on Thursday of the week specified no later than 1500 hrs.  So, where do you leave your homework?  Outside of Rand’s office there will be three boxes marked A, B, and C.  Leave your homework in the appropriate box (i.e., if you did the A homework, leave it in the A box, etc.).  Homework will be returned to you at the övning the following week.  You may work on the homework in groups of no more than 2.  If two of you have worked on a homework together, you must turn in only one paper with both your names on it.  You must also include your övning group number.  Your names, personnummer, and Group number must be clearly written in large friendly letters at the top of your papers. 


If two of you have worked on the homework together and happen to be in different övning groups, then you must decide which övning group number to put on your paper – that is the övning where the homework will be returned.  If you do not follow these instructions and put two övning groups on your paper, we will pick one at random and return the homework there.  Since only one of you will get your paper back at the övning and since the solutions will be discussed at the övning, I suggest that the one who will not be getting the paper back keep a copy to have during the övning for reference purposes.


Homework must be stapled together when you turn it in.  If you turn in pages that are not stapled together, they will be thrown away and you will get no credit.  Using string or tape or writing your name on each page or anything else you might have will just not cut it!!  Caution:  Do not ask Rand if you can borrow a stapler or even where you can find one – you will regret it.


Homework Format


For each program that you turn in, you must provide screen dumps showing your program in action on a range of example inputs (if any) that is sufficient to illustrate the range of capabilities of your program. (The whole screen is not necessary, just the relevant parts.  Please check out our screen dump instructions.)


You must also, of course, include the code itself.  Your programs must be clearly commented. For example, there must be enough comments at the beginning of your program to tell us roughly how your program works. This does not mean writing an English translation of each line of code. Furthermore, the code itself is not sufficient documentation. No documentation, no credit - even if the program works!


In some exercises you will be asked to implement one or more classes according to certain specifications that cannot be executed on their own.  A necessary part of the description of your results in that case is to show your classes in action.  The best way to do this is to build a small test program (often referred to as a driver program) that puts your classes through their paces.


For example, suppose you are asked to implement a Car class with certain features.  It would be nice to have some code that shows the class in action.  The question is, where do you put this code?  Well, it should not be part of the class definition because it has nothing to do with the class definition itself.  Instead, it should be part of a test class that might look as follows:

public class Test {
    public static void main(String[] args) {
        Car myBeemer = new Car(10);  // 10 kilometers per liter
        myBeemer.tank(80);  // tank 80 liters
        myBeemer.drive(100);  // drive 100 kilometers
        // print remaining fuel

This class should be put into a file called Test.   As far as the class being tested are concerned, you can either put them in the same file or in files of their own (preferred).  For example, you can store the Car class in a file called Car.java (remember to declare the class to be public and to have the file in the same directory as Test).   Note that Car will not need a main program in this situation (if there was one, it would not be called).  

In order to pass an assignment, you must have completed all the work specified correctly (more or less – mostly more). 


Homework 1 (Due week 38)


Homework 2 (Due week 39)