22c:016/106 Stuff


What did I submit? Check this listing. The first line should contain when it was last updated. Look for the group(s) that end with your userid.

The short list of only .java programs in the current project directories. Really make sure your files show up here!


Final grades should be posted no later than Sunday (12/22/02). If you would like to know what yours is ahead of time, you can email me.

Grades to date check these!

These are all the grades I have as of Saturday, Dec. 14. If you see anything amiss, please notify me BEFORE Friday! If you would like to pick up any previous projects, quizzes, or exams that I may still have, I will be in my office from noon to 1:00 pm on Monday, Dec. 16. You can probaby arrange something else by email if necessary.

A11 was the "quiz" from last Wednesday. If you don't know what I'm talking about, you should have attended lecture. :)


As promised, here is the code to my board game engine: Checkers.java. Except for the code for the mouse-driven player, there is nothing in it that we have not covered at some point. Loops, arrays, multidimensional arrays, objects, inheritance, graphics, polymorphism... Hmmm...


Project 10


Project 9


11/19/02: No discussion sections!

I will have office hours from 2:30-3:30, and will probably be around from 8:30-9:30 in the morning if you have any questions, but there is no official class meeting Tuesday.


Here is the altered version of the practice trace from Thursday. Try to figure out the output, then run it to check your answers. Note the shadowed variable in Obj2.

Another problem. Create a class Goldfish that describes goldfish. It should have instance variables the describe the color and size of the goldfish. It should also have a class variable that tells us how many goldish we have. It should also have an amountOfFood method that calculates the amount of food a goldfish eats each day (a goldfish eat 0.5 lbs of food per pound of size).
Now create a java program that asks the user for a number of fish to put in the pool, and the size of each fish in lbs. It should then print out the number of fish, the amount of food each fish eats per day, and the total amount of food we need per week.
An extension: create a subclass of Goldfish called Carp. Carp should also have a luck variable, but you should arrange it so that there is exactly one lucky carp. If you create another carp that is lucky, the previous ones should immediately become unlucky. Create an equals method that returns true if neither fish is the lucky one.


Here is the practice quiz I gave out on Thursday (the 3:30 version). Try to figure out the output, then run it to check your answers. Note the use of type promotion ("upcasting") from Obj2 to its superclass Obj1 in the copy() command. This will be covered in more detail when we go over polymorphism.


Project 8


BlackJack class


Be Warned!

The class drop deadline for undergrads is THIS MONDAY, November 4, at 4:30 pm.
Grades for the first half of the semester have been posted here. If you have a total score below 290, I strongly suggest you talk to either myself (you can set up an appointment by email) or Professor Bruell before this deadline.


Project 7


Recent files worked on during class:
Timer class (modified)
TimerTrial class (uses Timer)
initial BlackJack class (contains Card and Deck)
next BlackJack class (contains Card, Deck, and Hand)


How's this for a metaphore? A CLASS is sort of like a mold in a foundry. You only need one of them, and it describes (after a fashion) the shape of the many OBJECTS you can create using it. Each INSTANCE may be made out of a different alloy (different constructors make different state variable values), and may have different things put in it (different values in instance variables), but it will still have the same holes (instance variables) and pointy bits (methods).


Project 6

* Actually a file may compile if there is no public class, but don't get into the habit of doing this, especially as the compilers here sometimes don't recognize non-public class files correctly. This counts as a compilation error, so don't forget to include a public class! (The default permission is "package," out of private, protected, package, public). FOLLOWUP: Actually the HP-UX compiler does seem to handle a file containing a "package" class all right. It was my error in setting up my command line arguments for it that resulted in this mistake.


If you did not hand in a printout for project 5, you will get a 0 until you do so. I will grade it when you hand in the printout to me. If one of your problems did not compile and you did not mention any problems in comments/on the printout, you recieced 0 points for that problem. This time you may see me in person during office hours (or appt.) and I will take another look at this and possibly give some points back. I may not give this second chance in the future. So Domino/DominoTest WILL work as listed if put in two files (in the same directory).


Practice problems


Project 5:


Matrix example program (The problem from 8:30 was one of validation! I was trying to multiply matrices that were not of matching size. Frustrating, no?)


Project 4:


8:30 section GetVowels class

If JCreator is acting strangely -- it suddenly gives you new and unusual errors (like the JDK one) -- or you've somehow altered it accidently and want it back to the way it was, you can reset it from the start menu. So far this has cleared up all problems people have been having:


Next time... search & replace in a string? Censoring revisited!


Here is the source code for part of the Factoring problem I am going to go over on Thursday. Take a look at this version of the prime number generator (nextPrime()) and try to come up with the code for the (missing) factor() method on your own.

8:30 section solution

3:30 section solution

These solutions are different. It might be helpful to take a look at both of them.


Here are some notes from the quizzes. Also here is some general notes on programming, or at least some basic background information that you should keep in the back of your mind.

Also, Paula has been nice enough to post some answers for some of the the homework problems here. If you would like to go over any of these (or other problems) stop by my office hours, but really the best way to do this is to type out your solution in JCreator and make sure it compiles and runs (and if it doesn't, keep at it until it does).

Finally, I'll note that this course is very incremental. We will be constantly using things covered earlier in the course. If there is anything so far that you do not understand, now is the time to make sure you correct that! Don't get caught in a snowball effect because you didn't understand something from two or three weeks ago -- if you don't keep up, it will come back to haunt you!


Project 3:


Project 2:


Project 1:


Quiz 1:


JCreator webpage
We use the freeware LE package.


Older announcements


ghagen@cs.uiowa.edu