This semester, I took a dual enrollment Java programming class at Seminole State College of Florida. We covered everything from the basics to inheritance and custom exceptions.
One of the last projects we did of the semester was the Random Skyline project. During this project, we used JavaAWT and objectdraw to create an image of a city skyline. Objectdraw is not part of the Java Development Toolkit but is commonly used to teach introductory Java GUI programming.
The skyline is complete with a night sky, stars, a moon, and eight buildings of varying heights. Each time the program is run, the buildings’ height, the stars’ location, and the number and location of the windows that are lit change.
Overall, the project was easy for me. The main thing that gave me trouble was ensuring the windows would stay on the building with all the changes. I had to make sure I had a local variable that would keep track of each building’s height after the change was made to its height, to divide it by the window’s height, giving me the total number of windows I could have in each column of the building.
The biggest thing I took from this project was to keep track of the local variables. Since the heights of the buildings were changing so often, the local variable was getting lost in the calculations. One way to avoid this issue is to occasionally have the local variable print in the console while finishing the program or during the debugging process, so you can see the values change.