Wednesday, February 15, 2006

Object types

When objects are represented as classes, there are at least two ways to represent different kinds of objects. The easier one is to simply specify a data member that is different; for instance, color = BLACK, or color = WHITE, which serves to distinguish black pieces from white pieces. The other is when there is something about the structure or constraints about the object is different.

I decided to consolidate and rewrite my code a little to account for the various added concepts. I'm not including it here, but so far I've considered:

Space. This contains a number of cells or points, and a number of objects. I've flip-flopped on whether or not to explicitly include the points, and I've decided for now to include them.

Points. I'm using an aray to represent these. So far, these consist of a generic atribute and a pointer. This pointer points to the object that is in them. If I ever have multiple objects at the same point, I could make this a list of objects.

Particles. I'm including these in a list. Each has a position and one other attribute that I can make generic. Since the number of particles in space is rather arbitrary, I'm going to make a linked list, with add and remove operations.

Position: This is a number, pair of numbers, or triple of numbers depending on the definition of the space: for now, I'm making it a pair. The position of a point is implicit (It's related to space), but the position of an object is given as part of its data. It should be obvious that these must match: If I specify a location for a point in space, and there is a particle at that point, then the position given for the particle has to correspond to that point.

Position Coordinate. I've thought about making this an abstract class, because I want to include bounds-checking here. The coordinates must't be located outside the space, and there is no reason the bounds on the x-coordinate have to be the same as those on the y-coordinate.

Time. This works as a simple unsigned (positive) variable, so far.

Back when I was in school studying computer programming, I started but didn't finish a course on Windows programming. I did some study of it on my own, but I'm blurry on some of the technical details. I may include some of my observations on what I find here.
Input and display of positions, space properties, and object types is an important subject I can't ignore forever, but can push to the background for now. The next subject I want to consider is events.

2 Comments:

Anonymous Anonymous said...

Keep up the good work on the blog. I am interested in following the ideas you have on VWB.

10:32 AM

 
Blogger Confutus said...

Thank you. I welcome comments. Stick around and ask questions, if you like. I hope this process gets more interesting as I add features.

11:31 AM

 

Post a Comment

<< Home