Results 1 to 2 of 2
- 11-18-2011, 01:39 PM #1Member
- Join Date
- Nov 2011
- Rep Power
Best way to design a Pipe System?
So I have to design a Pipe System using netbeans.
I have the following details about the product:
How would you guys recommend I go about creating this? What/how many classes?
The variables are the diameter/radius, the length and the quantity.
I have so far created a checkLength class which allows the user to specify the length as a integer.
The type is essentially a name which is determined on the values the user chooses for colour, resistance, grade etc.....
The colour 0,1,2 refers to if the user is allowed a colour, and if yes 1 or 2 colours.
All help will be appreciated. Thanks.
- 11-18-2011, 10:55 PM #2
Re: Best way to design a Pipe System?
This is a classic example of what's called "modeling" in OOP. You want to model the real-world properties of something into a class.
Ultimately the objects you are modeling are pieces of pipe. So make a class called Pipe. (If you're modeling correctly, your class names will almost always be nouns.) Now think about what properties a piece of pipe has. Obviously it has a length, a diameter, and maybe some other dimensions like wall thickness. So you'd give your Pipe class some instance variables with appropriate names and types. A piece of pipe also has a material type, as shown in the chart you posted. That's a complex attribute, so you'd create another class called PipeType or PipeMaterial and give your Pipe class an instance variable of that type. That class would have instance variables for each column in the table you posted. Maybe two variables for the grade, min and max.
Take a shot at writing these classes, and post your code if you have more questions.Get in the habit of using standard Java naming conventions!
- By abdulsami in forum Advanced JavaReplies: 2Last Post: 02-17-2011, 06:15 AM
- By thejavaman in forum Advanced JavaReplies: 2Last Post: 10-18-2009, 01:41 AM
- By deschutron in forum Threads and SynchronizationReplies: 3Last Post: 10-03-2009, 11:48 AM
- By anji4u_19 in forum JDBCReplies: 0Last Post: 08-26-2008, 12:27 PM