• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Data Structure

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Object Name=new Object("Type", Parent);

E.g
Object Cube=new Object("Part", Root);
Root.Cube.Name="Cube4";
Root.Cube.Position=new Vector2D(0, 2);

How would I be able to make that?
 
lowercase baba
Posts: 13081
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
an example isn't really specs. Tell us what you really need to do.

I'm guessing you'll need a String, a reference to your class type, and a vector for the position...



then, write the various constructors/setters/getters.
 
Marshal
Posts: 76792
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agree with Fred about inserting data via your constructor. It is not good design to be able to write myFoo.field1.field2.
You don't say what Root is, but I would suggest you follow Fred's suggestion, assuming that fits the rest of the class. Label all your fields private, so you can't use the join-the-dots syntax.
 
Sheriff
Posts: 22696
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And never give your classes names of any existing classes from the java.lang package, like Integer, String or Object. You wouldn't be the first to get compiler errors because you meant java.lang.Object but were actually using your own Object class because it was in the same package.
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic