Monthly Archives: September 2015

It’s pretty but it doesn’t work

I sat down to rewrite the functions for moving objects. The title of this post describes the results: the new version didn’t move the objects.  Part of the difficulty is that my interface is cumbersome, which  I will have to work on later. I hope I can fix the bug by going through a walk-through of the function, but I will have to see.

I am still reviewing overloaded operation, stream Input and output, sequential files, and the use  of the struct data type: slow prograss, still.

I got the elevator simulation in the 3rd edition of Deitel & Deitel, apparently working, but its behavior seems odd. I may have to go through it again.

Success, or a success

Yesterday and today I have been struggling with trying to reformulate the physical system using pointers to physical objects instead of “true or false” markers to indicate their presence.  Nothing was working properly, but after laboring over it for a couple of days, I finally got the additions and deletions working properly. These should now work for any size, number, or distribution of objects (in a line).

The next project is to reformulate my motion functions, which work for size 1 objects, but a  size 2 object in a size 2 system should be immobile. As I increase the size system, the number of possible objects and complexity of their interactions increases.

I have also managed to get stubs for the three major functions of chemistry.  The sub-functions are important and structured differently enough that I need a greater variety of objects.

I also got a stub for the Solar System.  So far, this only has the names of the sun, major planets, and moons, and the three major groups of dwarf-planets and smaller objects.  More information, and the ability to work with that information, will come later.

Do I copy? Yes I do

I am still slowly tweaking necessities of dealing with physical objects. The last pass through my demonstration program produced more observations than code.

I am still making progress through the chapters on operator overloading, stream input and output, and file handling, and skipping ahead, to structures and character handling.   I spent far more time than I should have trying to debug my implementation of the elevator simulator, but I finally found and killed the bug. I had a false start on the game of Life in the data structures book, but I finally got the program skeleton, stubs, and the necessary input function all working together.   There’s still more copying than original programming, but in the process I get a chance to follow the logic of a program, what each statement does, and why it is necessary.  I would not get that if I simply copied the program from the disc that goes with a book.

New Stuff

I have decided, for now, that I am shifting the primary focus to using the tools I have acquired so far to build and refine the demonstration program.    I have revised the “Create a physical system” function to enter the size of an object. So far, I am still working with a tiny system of two spaces or elements, and getting the functions I want working within that system. Then, I can start working with larger systems. I extended the chemistry function to include a subfunction, substances. I can now enter the number of one of the first four elements and get a report on the number, symbol, and name.  There are more functions I can consider adding.  I don’t yet have a proper function for astronomy, but I do need to add one.

I also started to resume adding examples from the exercises, and in the process, reminded myself that the Culture section needs to be modified, and that I need to separate out my graphics functions into separate functions, and I also want to include an embryonic graphics processing function.

The review of my textbooks is going fairly well. I finished an example of an array class, and used a program that created a sequential file. I might note that at this point in my C++ programming class, I had had fallen far enough behind that I was avoiding the use of files; and I paid for this neglect in the more advanced classes,  In this review, I have begun reviewing the elementary features of linked data structures.

Coincidence

While I was tweaking my physical object  and physical system classes, I came across the curious result that physical objects were destroyed (the destructor called) twice more than they were created (constructor called).  I don’t understand how or why that is, but the program seems to be working anyway.

I was working on the demonstration for an Array class in my main text, and found an immediate solution for one of the problems in my Physical System class. That doesn’t happen very often.  I have finished the figures for D&D Chapter 7, and in chapter 8 I am again encountering familiar terms that I had not practiced with, so I seem to be learning something, anyway.

Working books

I’ve mostly done some progress on classes, using static members and functions, and with operator overloading, using the input stream and output stream.  These are more of the topics I didn’t really pay close attention to in my class 15 years, ago, so I’m it’s fairly new to me, but it is the kind of thing I need to get practice with.

The second book (K&R) is starting to involve exercises, which I want to pay attention to. This book has some review of the abstract data types I will be coming up on in my primary reference.

Moving slowly

I have made reasonably good progress over the past few days. I have finished the figures for chapter 6 of the main reference, and am about half way through chapter 7.  I’ve progressed a little further in the elevator simulation, and done a couple of rounds in the book on data structure, and the MFC book.

I took a stab at updating my demonstration program and got partway through separating out the system set-up commands, but this still isn’t quite working right.

New Book

Another programming textbook, that is. earlier this week I searched for C++ Windows programming textbook, and found  “Introduction to MFC Programming with Visual C++” by Richard M. Jones and ordered it online.  I got a second-hand version, with the disc, and it came within a few days,   After looking through it, it looks like just what the doctor ordered. The last few times I tried Windows programming, I hit Petzold (Charles F, Programming Windows, 5th Edition)  and bounced.  The Jones book looks more like it fits my current state of knowledge and ambition,  and it has Exercises.

For my demonstration program, I finished reviewing my various command functions and condensed the “science” commands.   I also  I also got one of the figures in my main textbook, Deitel done.  These are getting more and more involved, but it is necessary for me to work through them.

 

Evolution

Each version of  my program reveals now features that need to be added, or revised, or tweaked, sometimes before the next step I had intended.  The difficulty of dealing with dozens of commands  and reworking the list has led to more intensive effort on separating and recognizing the categories.

I have now separated physical system commands into two categories: system setup, and mechanics. The elevator simulation has given me some ideas on how to handle the relationship between the a physical system and the objects in it.

Working the work

I mostly succeeded in separating out my various arithmetic functions, so that when I go adding more of them, they will have appropriate places to go.

I converted the “main” function of my demonstration program  from a switch statement to using an array of pointers to functions. I like this approach much better. One of the things that has slowed my development down is that when I add a new function and the need to invoke it, I need to renumber too many commands. I need to break these into categories, which should simplify the processing.

I added a new class to the program: Physical objects. These are still not yet well coordinated with physical systems, but I want to begin working on them.  I have also rewritten and simplified the logic of my move functions.

For the elevator simulation, I have added a couple of classes and part of their implementation,