Thread: Best way of organizing.

  1. #1
    Set Apart -- jrahhali's Avatar
    Join Date
    Nov 2002
    Posts
    256

    Best way of organizing.

    hello.
    I am attempting to write a program that allows the user to enter and element from the periodic table and then displays some information on that element. I was wondering how you would go about organizing a program liek this since theirs TOO MANY ELEMENTS! any suggestions and oppinions are welcome

  2. #2
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    You could write a class for the elements that contains their atomic weights, numbers, etc. Stick all of them in a container like an array or a vector and then access them as necessary.

    You could stick all of the info into a file. Read in the file until you reach the entry you want. Then, output the info that the file contains on that element.

    As for what's best, that's rather subjective. Writing a class for elements is perhaps more time consuming than you want. Oh, and there are only around 116 elements. That's diddly in the scope of computer science. Databases contain terabytes of information.

    Ooh, that just gave me an idea. You could just whip up a database in Access and query it as needed, but I'm assuming you need to write this program for a C++ class, so I guess that idea's out the window.
    Last edited by joshdick; 10-21-2003 at 07:11 PM.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  3. #3
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    I personally would say go with a file... that way you can write a quick patch if something changes without breaking into the source... but then you'll get a stupid user who likes to delete or mess with the data file... I think it's alot slower too...

    on the other hand, the elements most people need don't change often at all, so your pretty safe writing them into the program...

    edit: I just thought of a way to do it with the text file that would give you some good practice... create a data file like i said, then when the program initializes, have it read each element onto it's own node in a linked list...
    Last edited by major_small; 10-22-2003 at 07:04 AM.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. organizing data types
    By l2u in forum C++ Programming
    Replies: 1
    Last Post: 09-26-2008, 08:52 AM
  2. organizing window handles
    By FOOTOO in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 11:53 PM
  3. Suggestions on Organizing Files
    By jrahhali in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 10-09-2004, 01:15 AM
  4. planning and organizing for bigger projects
    By m00se123 in forum Game Programming
    Replies: 2
    Last Post: 10-28-2002, 02:49 PM
  5. Self Organizing Lists
    By Bradley in forum C++ Programming
    Replies: 0
    Last Post: 12-05-2001, 06:45 PM