View Full Version : enlarging a box

04-15-2008, 06:40 PM
I am having problems understanding how to complete this task.

Specify by how much larger (multiplier) you would like to enlarge each dimension of the object. For example, makeLarger(2) would multiply the length, width, and height of the box by 2.
Specify the specific amount you would like to add to each dimension of the box. For example, makeLarger(1, 3, 5) would add 1 to the length, 3 to the width, and 5 to the height of the box

my code that i have written in order to make the boxes looks like this:

public class Box1 {

double length;
double width;
double height;

Box1() {
length = 10;
width = 10;
height = 10;
//makes a defalt box
Box1(double l, double w, double h) {
length = l;
width = w;
height = h;
//makes a user created box
Box1(double s){
length = s;
width = s;
height = s;
//makes a cube

any tips on how to make a method to peform the objectives in the task above?

04-15-2008, 07:59 PM
What you're asking is a very basic concept in Java (and in programming in general).

My suggestion is that you either read up on the book you are reading for your class about construction of Java objects and methods within a class or you start going through the Java tutorial on the subject:


If you did indeed write that code, then you're on the right track. If you didn't and it was your instructor then I suggest you start from the beginning of the Java tutorial and go through it.

As for tips on writing a method think of these main things:

What will the method return?
What will the method get from the user (the parameters)?
How will the data change inside the method?