Click to See Complete Forum and Search --> : Debugging help!


lavina
04-14-2004, 11:59 AM
Hi, I need to debug these two small projects and I can't really seem to find anything wrong with it. I'm new at this and the project does have errors but I can not seem to find them. Here is the project:


/**
* A palette is a stack of bricks on a wooden base.
*
* @author: Michael Kolling
* @version: 2002.02.08
*/
public class Palette
{
// constants:
private static final double baseWeight = 6.5; // in kg
private static final double baseHeight = 15; // in cm

private Brick aBrick;
private int bricksInPlane;
private int height;

/**
* Create a palette with a given number of bricks.
* 'bricksInPlane' is the number of bricks in each level on the base.
* 'height' is the number of bricks stacked on top of each other.
*/
public Palette(int bricksInPlane, int height)
{
this.bricksInPlane = bricksInPlane;
this.height = height;
aBrick = new Brick(8, 20, 12);
}

/**
* Return the base of the palette (in kg)
*/
public double getWeight()
{
int numberOfBricks = bricksInPlane * height;
return aBrick.getWeight() * numberOfBricks;
}

/**
* Return the height of this stack (in cm)
*/
public double getHeight()
{
return (aBrick.getHeight() % height) + baseHeight;
}
}


Project 2:

/**
* Class Brick - models a simple brick.
*
* @author: Michael Kolling
* @version: 2002.02.08
*/
public class Brick
{
// Constant.
private static final int WEIGHT_PER_CM3 = 2; // weight per cubic cm in grams

// instance variables:
private int height;
private int width;
private int depth;

/**
* Create a Brick. Parameters are edge lengths in centimeters.
*/
public Brick(int height, int width, int depth)
{
this.height = height;
this.width = width;
this.depth = depth;
}

/**
* Return the surface area of this brick in square centimeters.
*/
public double getSurfaceArea()
{
double side1 = width * height;
double side2 = width * depth;
double side3 = depth * height;
double total = (side1 + side2 + side3) * 2;

return total;
}

/**
* Return the weight of this brick in kg.
*/
public double getWeight()
{
return (getVolume() * WEIGHT_PER_CM3) / 1000;
}

/**
* Return the volume of this brick in qubic centimeters.
*/
public int getVolume()
{
return width * height * depth;
}

public double getHeight()
{
return height;
}
}

buntine
04-14-2004, 12:24 PM
Can you please post the errors you are receiving when the files are compiled? We wil be able to see what we are looking for then.

Also, this post should be in the 'Scripting - Other' forum. ;)

Regards,
Andrew Buntine.

lavina
04-14-2004, 01:39 PM
The scripting what forum..uh, sorry new to the site. Well if anyone could help it would be great. I tried to post it in script form but it was all in a folder and there was no way I could have put all the files on here. So I copied the code and posted it.

buntine
04-14-2004, 02:21 PM
Ok, but you said that the application contains errors... Can you please post these errors so we know what we have to fix? Or atleast what we are looking for.

The 'Scripting - Other' forum is a little further down from the General forum.

Regards.