• 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

Calculator

 
Ranch Hand
Posts: 119
Mac Eclipse IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm just messing around and rewriting a program I'd been working on several months ago -- hopefully end up with a slightly more sophisticated physics calculator. I was hoping you guys could provide me with a little insight. Right now I have just the main, gui, and kinematics classes, eventually, I will add the other areas of physics. The program will open with a main menu where the user can select a topic and they can enter the data into JTFs. Now, when I wrote this program the first time I used a lot of accessor methods(for each variable in the class(topic) ) that it just looked messy, so I want to get rid of those and use something else.

Do you have any ideas how I might accomplish this? I had considered using a list, when the user chooses a field to enter (ex: kinematics) it will initiate a list of type Kinematic.

Also, last time I had an issue with determining which calculations to perform based on the information entered. For instance, if the user left more than 2 JTF's blank (2 variables), but only enough data was given to solve for 1.....how can one account for this in there code? Aside from trying to perform each calculation in the class and breaking from any calculation that has more than one variable...I'm not sure what to do.

this is just a rough example to the kinematics class to give you a better picture of what I'm trying to do.



 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's a JTF? Some sort of text field?
Does that loop run without an Exception?
Those are't accessor methods as you call them in the comments. Some of them are mutator methods. Don't use blocks of ////. They might look pretty but the correct form of comments would be documentation comments with /**…*/ for each method.

If you are going on about text fields at this stage of the proceedings, I think you are doing things in the wrong order. Create a class with methods like getAcceleration and getOriginalVelocity. Consider whether those should be instance methods in which case you would need to have the data as six fields, or whether to have them as static methods in a utility class in which case each of the six methods needs the other five data passing as parameters. I don't like the switch in that sort of program because it will be difficult to call from a Listener. Consider what to do with this sort of rubbish input:-Get the kinematic class working at the command line/terminal and then consider adding a GUI.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic