• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object Definition question  RSS feed

 
Tempora Telora
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,
I am writing a program that will have alot of various input. I am thinking about sorting all of this by project name. Should i have my object name be the project name.. Project SKW004 = new Project(); But am i able to search each project for certain material? System.in project name to search for.
How do i search through all the records for the dates? Or should i just have the project be an array that increments as you store objects?
If Project.Date = 05162005
{}
else blah

can i do that?
 
Nigel Browne
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is confusing me so no wonder you are confused. When thinking about object design, identify the thing it is you want to model (in this case a project), then work out the attributes the project will have e.g. a project name, a reference number e.t.c. these become your variables. Finally think about the behaviour the project will have. e.g. setName getName e.t.c these become your methods.
Next try to put all this together in a class file. I post a template to get you started
I hope this helps
 
Ryan McGuire
Ranch Hand
Posts: 1143
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either have the project name as a field in Project, as Nigel suggested, and put them all in some collection (an array, a Vector, etc.) or you can use a Map (HashMap, Hashtable, etc.) to allow you to get at the Project that associated with a given project name (String).

So instead of
SKW004.Date = "05162005";
you'd have something like
((Project)projectMap.get("SKW004")).Date = "05162005";
or even
((Project)projectMap.get(inputProjectName)).Date = "05162005";

Cool?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!