The following are in reverse chronological order.
Plagiarism and academic honesty guidelines: Each student does his/her own project although you may ask other students and/or me about clarifying the project or for ideas about how to approach doing something in the project. You will do all the computer work yourself (including typing and mousing) and not allow another student to copy your work and not yourself turn in work copied from someone else. You will not ``dictate'' mousing and typing to another student nor be ``dictated'' to yourself.
mount -t vfat /dev/sdb1 /media/sdb1 mount -o remount,rw /dev/sdb1 losetup /dev/loop4 /media/sdb1/knoppix.img fsck /dev/loop4 losetup -d /dev/loop4 umount /dev/sdb1 exit
public int joinedInMonth(int month) {
if (month < 1 || month > 12) {
System.out.println(month + " is out of range");
return 0;
}
int howMany = 0;
for (Membership member : roster) {
if (member.getMonth() == month) {
howMany++;
}
}
return howMany;
}
public ArrayList<Membership> purge(int month) {
ArrayList<Membership> purged = new ArrayList<Membership>();
int positionNumber = 0;
while (positionNumber < roster.size()) {
Membership member = roster.get(positionNumber);
if (member.getMonth() == month) {
purged.add(member);
roster.remove(positionNumber);
} else {
positionNumber++;
}
}
return purged;
}
public Lot getLot(int lotNumber) {
if((lotNumber >= 1) && (lotNumber < nextLotNumber)) {
for (Lot lot : lots) {
if (lot.getNumber() == lotNumber) {
return lot;
}
}
System.out.println("No lot found with lot number matching " + lotNumber);
return null;
} else {
System.out.println("Lot number: " + lotNumber + " does not exist.");
return null;
}
}
public void close() {
for (Lot lot : lots) {
if (lot.getHighestBid() == null) {
System.out.println("The lot of " + lot.getDescription() + " is unsold"
+ " (serial number " + lot.getNumber() + ").");
} else {
System.out.println("The lot of " + lot.getDescription() + " sold for "
+ lot.getHighestBid().getValue() + " to "
+ lot.getHighestBid().getBidder().getName());
}
}
}
public ArrayList<Lot> getUnsold() {
ArrayList<Lot> unsold = new ArrayList<Lot>();
for (Lot lot : lots) {
if (lot.getHighestBid() == null) {
unsold.add(lot);
}
}
return unsold;
}
public Lot removeLot(int lotNumber) {
int positionNumber = 0;
while (positionNumber < lots.size()) {
Lot lot = lots.get(positionNumber);
if (lot.getNumber() == lotNumber) {
lots.remove(positionNumber);
return lot;
}
positionNumber++;
}
System.out.println("No lot found with lot number matching " + lotNumber);
return null;
}
/**
* Twelve-hour clock display. Internal time is a 24 hour clock.
*/
class ClockDisplay {
private NumberDisplay hours = new NumberDisplay(24);
private NumberDisplay hours12 = new NumberDisplay(9876); // limit unused
private NumberDisplay minutes = new NumberDisplay(60);
private String display12String; // simulates the actual 12 hour display
private String displayString; // simulates the actual 24 hour display
...
private void updateDisplay() {
String ampm;
displayString = hours.getDisplayValue() + ":" + minutes.getDisplayValue();
if (hours.getValue() == 0) hours12.setValue(12);
else if (hours.getValue() > 12) hours12.setValue(hours.getValue() - 12);
else hours12.setValue(hours.getValue());
if (hours.getValue() < 12) ampm = " am";
else ampm = " pm";
display12String = hours12.getDisplayValue() + ":" + minutes.getDisplayValue() + ampm;
}
}
Don't forget the TAB and ENTER keys when the gray dialog box appears.boot: knoppix bootfrom=/dev/sda1/knoppix.iso
/**
* A better Planet class: encapsulation, information hiding,
* responsibility-based design. The original Planet class
* depended on code somewhere else to calculate new (x, y)
* coordinates as the planet object moves in orbit around
* the sun. This Planet class is responsible for making those
* calculations itself when it is told to move (an action method).
* Also the original Planet class was vulnerable to some incorrect
* code somewhere else setting x or y to an arbitrary value, taking
* the planet out of its elliptical orbit, clearly a bug (error).
*
* @author Computer Science and Programming
* @version 2007.01.24
*/
class Planet {
private int size; // diameter in miles
private String color;
private String name;
private int x; // coordinate in miles, sun is at (0, 0)
private int y;
private int majorAxis; // elliptical orbit diameter in miles
private int minorAxis;
private int lengthOfYear; // seconds
public Planet(int s, String c, String n, int ix, int iy, int ma, int mi, int y) {
size = s;
color = c;
name = n;
x = ix;
y = iy;
majorAxis = ma;
minorAxis = mi;
lengthOfYear = y;
// Put code here to make sure that s, ix, iy, ma, mi, and y are not
// negative. Also, put code here to make sure that (x, y) lie on
// the elliptical orbit. Print error messages (or throw a runtime
// error) if any of these tests fail.
}
public String getName() {
return name;
}
public String getColor() {
return color;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
// Put other `get' (query) methods here.
/**
* Move the planet object to where it will be in so many
* seconds in the future.
* @param seconds the number of seconds in the future
*/
public void move(int seconds) {
int deltax = 0;
int deltay = 0;
// Put code here to calculate the (deltax, deltay) values to move
// the planet to where it will be `seconds' in the future.
x = x + deltax;
y = y + deltay;
}
}
home page:
http://elvis.rowan.edu/~hartley/index.html
e-mail:
hartley@elvis.rowan.edu