• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need suggestions on my Java Project

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

before i start asking questions, let me explain what kind of java project im doing and what im aiming for.

I wana write a Programm to visualize and calculate a pipe system.

1.The user should be able to create vertical pipes at will, that have different radii, a position in space (x, y, z) and a volumetric flow rate (how much water flows through the pipe per second).
2. The user should then be able to connect those vertical pipes using a main connection, again setting a radius and secondly telling the connection which vertical pipes should be connected with each other. The main connection should be in a series, meaning if you use a connection to connect vertical pipe a with vertical pipe b, youre free to choose what vertical pipe the main connection goes to next, but it has to come from vertical pipe b.
3. The user sets the koordinates of the end of the main connection again any position in space.
4. If there are any unconnected vertical pipes, the user should be able to connect them to the main connection using side connections, beeing able to set the radii.
5. A few calculations should be done, for example summing up all the volumetric flow rates. Another example would be calculating the slope of all the connections (since two vertical pipes dont necessarily have the same lenths).
6. The input should be done using a GUI.
7. The pipesystem should be visualized.

Ive thought of having a class pipe, that has all the attributes a pipe can have and then some sub-classes for the vertical pipes, the main and side connections and the end of the pipe.
In another class called pipesystem i would have ArrayLists for each time of pipe.

The first big problem i encounter is when i try to connect the main connection, since within the array some sort of if () method has to be implemented (atleast i think so) that only allowes the user to place the main connection in a series.

The second thing i have no clue about is, how to use the Data from the ArrayLists for calculations. I know how to do a sum of an array list. However, in my programm i only need to sum up a certain value of an object from an arraylist if you know what i mean.

I would be pleased to get some help, since i havent found anything on the internet that uses values from objects in arraylists to do calculations.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Phil

I can help you with the second part of your question, I have created a simple value object class (VO) with three integer values (ExampleVO) , then I created two mock objects of the VO class (vo1 and vo2), then I added them to an ArrayList.

Finally I created an Iterator from that array list (myIterator) and I iterate through all the objects inside the list and I can specify which value to use by using the getter method from the VO object.

See code below, hope this helps.

 
David Podolski
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, here is the code for the ExampleVO class, just to show how a VO works.

 
phil mataz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. Let me post to you what i've got so far.




This is my main() class:



My method that gives the sum of all the flow rates does work, but ive read alot about Integer now, i just seem to not quite understand how to use it. Even i the classes use posted, i understand everbit of code until i read "Integer" and my mind goes blank. I know, since it works that i dont need an Integer for my Method. However, there must be a reason why Integer exists. Could you please give it a try at explaining it to me? I know its kind of funny, since you get a hell lot of results when googeling "Integer Java", the problem isnt that im not looking it up, i seem to just not understand it.

Thanks.
 
David Podolski
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Phil

Maybe you can explain why you think your code is not working? I ran your test class and I get an output of 310.0 which is the sum of all your "zulaufmenge" variables inside your mock objects (s1, s2, s3, s4, s5). So if you were trying to add up the variables it has worked (60 + 50 + 50 + 50 + 100). I suspect that you are trying to do something else however. But I do not fully understand what.

Integer is something you use when you don't need any floating point numbers, so if my variable was only working with whole numbers and no fractions I would use Integer (e.g. amount of cars driving past a point on a highway can only be 1, 2, 3 or 127653 but it can never be 2,33).
 
phil mataz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, thanks for you reply.

My method does do, what i want it to. One of my friends, helped me with that method. But he thinks, that its not the best way of solving the problem.

Also i dont understand this part:



Why do we have to create a new Schacht (that is not even added to the ArrayList), when were only trying to access the schaechte ArrayList.
 
David Podolski
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need to I didn't mention it but, the better way of doing that part would be:

 
We noticed he had no friends. So we gave him this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic