Project #1241 - Basic Java

 

Create a class named Box that includes integer data fields for length, width and height. Create three constructors that require one, two and three arguments, respectively. Code the constructors as follows:

?h The constructor that takes one argument should assign the value to length and assign zeros to height and width. This constructor should also print a line of text that says, "Line created with length XX". Be sure to replace the 'XXX' with the value of length using the Java keyword this in your code.

?h The constructor that takes two arguments should assign the first value to length, the second to width and zero to height. This constructor should also print a line of text that says, "Rectangle created with length XXX and width XXX". Be sure to replace the 'XXX' with the values of length and width using the Java keyword this in your code.

?h The constructor that takes three arguments should assign the first value to length, the second to width and the third to height. This constructor should also print a line of text that says, "Box created with length XXX, width XXX, and height XXX". Be sure to replace the 'XXX' with the values of length, width and height using the Java keyword this in your code.

When you are finished writing this class, write a second class called BoxTest that tests each of the constructors and demonstrates that each works correctly. You may use any values for length, width and height in your program or you can prompt the user to enter these values.

Although the output of your program is not required to look this way, it might look something like:

Line created with length 5. Rectangle created with length 10 and width 15. Box created with length 1, width 2, and height 3.

Once your program works correctly, be sure to submit both the Box.java and BoxText.java files for grading.

Subject Computer
Due By (Pacific Time) 11/20/2012 12:00 am
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy