Design and implement a class called Box that contains instance data that represents the height, width, and depth of the box. Also include a boolean variable called full as instance data that represents if the box is full or not. Define the Box constructor to accept and initialize the height, width, and depth of the box. Each newly created Box is empty (the constructor should initialize full to false). Include getter and setter methods for all instance data. Include a toString method that returns a one-line description of the box. Create a driver class called BoxTest, whose main method instantiates and updates several Box object
Can someone provide me a structure type of template that shows me how to design this class? Any comments or suggestions are highly welcomed. Thank you
> Can someone provide me a structure type of template that shows me how > to design this class? Any comments or suggestions are highly welcomed. > Thank you >
Don't aks people to do your homework for you. Otherwise you are cheating yourself out of an education. Make an attempt and then ask for help with specific points that you cannot solve. Break it down into small steps.
> Design and implement a class called Box
You are going to have something like:
class Box { // some declarations, constructors and other methods go here
} > that contains instance data > that represents the height, width, and depth of the box.
You are going to insert this somewhere in your code:
int height, width, depth;
But consider what data type these variables should be, maybe floating point is more appropriate? Perhaps it doesn't matter for this exercise?
> Also include a > boolean variable called full as instance data that represents if the > box is full or not.
You should be able to work out what to do.
> Define the Box constructor to accept and initialize > the height, width, and depth of the box.
Note that the Eclipse IDE can create a constructor for you once the above parts are in place.
> Each newly created Box is > empty (the constructor should initialize full to false). Include getter > and setter methods for all instance data. Include a toString method > that returns a one-line description of the box. Create a driver class > called BoxTest, whose main method instantiates and updates several Box > object
Carry on breaking the above into small steps and implement each step one at a time, see if you can coompile it at each stage and work out what any error messages mean. Where possible, eliminate any errors before implementing the next part of the specification.
digiboos...@gmail.com wrote: > Design and implement a class called Box that contains instance data > that represents the height, width, and depth of the box. Also include a > boolean variable called full as instance data that represents if the > box is full or not. Define the Box constructor to accept and initialize > the height, width, and depth of the box. Each newly created Box is > empty (the constructor should initialize full to false). Include getter > and setter methods for all instance data. Include a toString method > that returns a one-line description of the box. Create a driver class > called BoxTest, whose main method instantiates and updates several Box > object
> Can someone provide me a structure type of template that shows me how > to design this class? Any comments or suggestions are highly welcomed. > Thank you
hi,
Hope following code will help you.
//Box.java
/** * */ package com.omitdev.box;
/** * @author Kalyani Alshi * */ public class Box {
> digiboos...@gmail.com wrote: >> Design and implement a class called Box that contains instance data >> that represents the height, width, and depth of the box. Also include a >> boolean variable called full as instance data that represents if the >> box is full or not. Define the Box constructor to accept and initialize >> the height, width, and depth of the box. Each newly created Box is >> empty (the constructor should initialize full to false). Include getter >> and setter methods for all instance data. Include a toString method >> that returns a one-line description of the box. Create a driver class >> called BoxTest, whose main method instantiates and updates several Box >> object
>> Can someone provide me a structure type of template that shows me how >> to design this class? Any comments or suggestions are highly welcomed. >> Thank you
> hi,
> Hope following code will help you.
<snip code>
Wow, that's a pretty excessive hint. Are you going to take the test for him also?
digiboos...@gmail.com wrote: > Design and implement a class called Box that contains instance data > that represents the height, width, and depth of the box.
Andy Dingley wrote: > digiboos...@gmail.com wrote:
> > Design and implement a class called Box that contains instance data > > that represents the height, width, and depth of the box.
> throw new HomeworkException();
Yes It is part of my homework. It is the one I am stucked at. I am asking nicely for some hint. If you know something and don't want to tell me, you don't have to laugh at me instead.
> Yes It is part of my homework. It is the one I am stucked at. I am > asking nicely for some hint. If you know something and don't want to > tell me, you don't have to laugh at me instead.
You weren't asking for a hint, you were asking for us to show you how to do it. And we're not laughing at you, it's really for your own good in the long run. The link Matt posted is worth taking a look at, and bears repeating: http://mindprod.com/jgloss/homework.html
Give that a read, and try to see where we're coming from!
This was what I wrote: Can someone provide me a structure type of template that shows me how to design this class? Any comments or suggestions are highly welcomed. Thank you
All I am asking for is a structure type of thing that can get me started. I've never asked for any code. A nice easy template is all I was asking for. Maybe it is the question I copied and paste scared people. Thanks for your concern, and I totally understand that I need to learn this stuff on my own.
Joe Attardi wrote: > On Oct 16, 3:04 pm, digiboos...@gmail.com wrote: > > Yes It is part of my homework. It is the one I am stucked at. I am > > asking nicely for some hint. If you know something and don't want to > > tell me, you don't have to laugh at me instead.
> You weren't asking for a hint, you were asking for us to show you how > to do it. And we're not laughing at you, it's really for your own good > in the long run. > The link Matt posted is worth taking a look at, and bears repeating: > http://mindprod.com/jgloss/homework.html
> Give that a read, and try to see where we're coming from!
digiboos...@gmail.com wrote: > This was what I wrote: > Can someone provide me a structure type of template that shows me how > to design this class? Any comments or suggestions are highly welcomed. .. > All I am asking for is a structure type of thing that can get me > started.
class ClassName { //insert code here..
} >... I've never asked for any code.
Ummm.. OK, so what do you want this 'template' written in? Will Tanu-Tuvan do?
> All I am asking for is a structure type of thing that can get me > started. I've never asked for any code. A nice easy template is all I
The point is that the code for this exercise is so simple that giving you a template solves half you homework. A better approach to getting help on these news groups is to ask specific question. So if you don't understand what to do, ask if any of us can explain what is to be done, that's a completely different question from asking about providing the answer. If you don't know where to start, ask us for a hint, if you have a compilation or design problem, show us how you have solved it so far and ask what you must look for to fix it.
As I stated, reading the first couple of chapters of a java book will give you enough information to figure out the template for the homework yourself.
digiboos...@gmail.com wrote: > Yes It is part of my homework.
So why not _do_ your homework, as you're meant to? What is your excuse? You clearly haven't even tried to start on this problem. It's a poorly phrased question and gives you far too much help to begin with -- even with this much help you didn't make any attempt to even begin it. Why can't you understand it? Are you very, very lazy? Were you asleep in the classes? Do your parents know that they are wasting their money on classes that you are trying to cheat your way through?
> I am asking nicely for some hint.
No, you didn't "ask" for a "hint", you re-posted the whole question, with no contribution from you. None at all.
Andy Dingley wrote: > digiboos...@gmail.com wrote:
> > Yes It is part of my homework.
> So why not _do_ your homework, as you're meant to? What is your > excuse? > You clearly haven't even tried to start on this problem. It's a poorly > phrased question and gives you far too much help to begin with -- even > with this much help you didn't make any attempt to even begin it. Why > can't you understand it? Are you very, very lazy? Were you asleep in > the classes? Do your parents know that they are wasting their money on > classes that you are trying to cheat your way through?
> > I am asking nicely for some hint.
> No, you didn't "ask" for a "hint", you re-posted the whole question, > with no contribution from you. None at all.