Some examples of sorting algorithms are in Sort.
Binary and linear Search algorithms examples.
The Java class Gambler uses two-dimensional Vector to implement a dynamic version of Pascal's Triangle.
Java classes Mistakes and TestMistakes are full of errors. Try to eliminate these errors, one-by-one, and keep track of whether the error occurs at run-time or compile time. If you succeed with those, here is a really weird error to think about.
During Week 8 we looked at strategies for testing code, by
developing an equals
method for class Name after we had already developed test
cases and a class, TestName, for
automating the tests.
In Week 7 we left Object Oriented code aside and looked at some examples of loops. I have included the loop conditions and postconditions we discussed in class.
In Week 6 Species gets a modified
constructor, to allow the specification of
maxPopulation
and birthRate
. With
those attributes, a Species can breed and die off following the
logistic equation. The EcoSystem now takes a species
through a few life cycles.
In Week 5 Species class gains a
toString()
method, and an
equals(Species)
method. It also gains a field
territory
in case we need to distinguish species by
territory. EcoSystem is modified
appropriately.
In the Week 4 Species class, we add the ability to keep track of how many species have been created. In the EcoSystem class, we have file I/O to and from text files.
Here are the Species and EcoSystem classes from Week 3.
Species
now has a constructor that sets its name
and population when it is created. EcoSystem
now
uses a BufferedReader
to get input from the
keyboard.
These are the Species and EcoSystem examples from Week 2. There are new methods to breed, die off, set a species' name, and set a species' population.
These are the Species and EcoSystem examples from Week 1.