Program Ideas

Pages: 12
Can anyone give me pretty advanced program ideas. Thanks a lot!
Last edited on
I think you should be more specific. What skill level are you looking for?
I would love to see a library of classes that can calculate anything! Examples of classes: Temperature, Distance, Mass. They all require a specification of the units. Example: Temperature can be in Celsius, Kelvin, Farenheit or Ranking (I think! hehe, I'm not 100% of the last one). I want to be able to operate on them without regard of the units of the two objects:

1
2
3
Temperature T1(30, Celcius);
Temperature T2(50, Farenheit);
Temperature sum = T1 + T2; //and sum should represent the value 40 Celsius. 


Another example: Be able to divide 100 meters by 10 feet and obtain the proper dimensionless value of 32,808398950131233595800524934383.

If all this is too simple, then start thinking about compound dimensions. Examples: Speed (distance/time), acceleration (distance/time/time), force (mass * acceleration), etc.
Thanks, that sounds good, and long, so ill have to think of a way to shorten it.
Here's a question, how would you implement webJoses code as it? As in don't require the user to pass a string? There's a pretty simple solution, don't over think it.
Use switch function
And?...
Not sure...
Oh, classes
Not quite. I was refering to "enum{...}". Although classes would work enumerating the values would be much less work.
Want to work on a library of classes together? We could make a great program! So who's up for the idea?


I have created a library of classes topic. Work for the program will be on that topic.
Sure, start with a base class for webJose's idea. Something that would take the value passed to the constructor and set that as a base value for the object. Let's also use the enumerated value to designate the function pointer which would determine the format of the value >:D!!!! This could be FUN! It's getting so obfuscated I'm having trouble describing what's going through my head!
Post your idea on Library of Classes topic.
We'll continue working there.
hehe, don't think for a second that this is trivial in any way. This is complex anywhere you look at it. Good luck guys. I can promise it will be fun, though.

One more degree of complication: My temperatures example is really not accurate. Temperatures are like times: They have a "zero reference". You can add a time span to a time and get a time, and you can add a temperature difference to a temperature and get a temperature, but it is incorrect to add two times or two temperatures. The sumation doesn't have physical meaning. In pseudo code:

1
2
3
4
5
Temperature T1(30, Celsius);
Temperature T2(40, Farenheit);
TemperatureDifference dT = T2 - T1; //This is OK.
Temperature T3 = T1 + T2; //This really isn't OK.  This should not be allowed.
Temperature T3 = Temperature(100, Kelvin) + dT; //This is OK as it adds a temp. difference to a temperature object. 


Same goes for times. For temperatures it is more critical. Example: 10 C - 9 C = 1 dC (dC = "delta" Celsius). If you don't treat this as a different class, a conversion from C to F would incorrectly say that 1 dC = 33.8 dF, when in fact it is only 1.8 dF.

hehe, am I ruining the fun? :-) Again, good luck!
Last edited on
So how should we start it off? Of course with:
1
2
3
4
#include <cstdlib>
#include <iostream>

using namespace std;
You shouldn't use any namespaces when you're building libraries. It may cause problems if anyone else tries to use it.

EDIT: Also what is cstdlib.h for?
Last edited on
hehe, the million bucks question! You need to start getting away from the keyboard and design. If you rush into code you will not hit the mark. For example: How will you be treating the different units? Enumerations? Classes? If classes, will you use a base Unit class for all classes for all dimensions? Are you going to tackle compound dimensions like area, speed, acceleration? If yes, how will you make those work so that a programmer can do:

1
2
3
4
5
6
7
8
9
10
Distance = testedDistance;
cout << "Enter the distance traveled by the test vehicle: ":
cin >> testedDistance;
Time runningTime;
cout << "Enter the time the vehicle took to travel the distance: ";
cin >> runningTime;
Speed measuredSpeed = testedDistance / runningTime;
//Or using a constructor so I can decide the speed units, like kilometers per hour:
Speed measuredSpeed(testedDistance, runningTime, Kilometer, Hour);
cout << "The measured speed was " << measuredSpeed << "." << endl;


And that raises another question: Is Kilometer any different from meter? Or should the Kilo part be translated as it is, a multiplier of 1000? What about all other prefixes like Deca, Hecto, Mega, Giga, Tera? What about the small ones (deci, centi, milli, micro, etc.)?

This is no small project, I tell ya!
I just answered this in the other thread that the OP created. A different base class for each of the observable dimensions.

EXAMPLE:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
template<class M>
class Base_Class_One
{
            private:
                   M magnitude;
/* Code code code...*/
};

template<class M, class D>
class Base_Class_Two
{
           private:
                   M magnitude;
                   D direction;
/* Code code code...*/
};

And so on...
Last edited on
Pages: 12