Author Archives: mikesprogrammingblog

Week of September 11, 2023

This week, I reviewed chapter 8 from Learning Java by Building Android Games 3rd Edition by John Horton. This chapter reviews some of the principles of object-oriented programming, including encapsulation, inheritance, and polymorphism. Interestingly, the principle of abstraction that was named alongside the previous three in the course syllabus is not reviewed in this chapter of the book. I chose to write about this resource because in the last Spring semester, I studied this book in order to create a functional mobile game in Android Studio for my final project in my Operating Systems course. I needed to apply my knowledge of arrays, for and while loops, and Java class design to complete this project. In addition, I needed to learn how to utilize the graphics libraries within Android Studio to visually represent the entities within the game and how they interacted with each other. While this book did help me tremendously in the later stages of the project, I wish I had found it earlier before I began coding. I had begun the project in BlueJ, and was coding a Java app meant to be run on a Windows or Mac system, not an Android mobile device as was the project specification. I completed a functioning version of the game with all the features I wanted to include that ran on my Windows PC, but I found it much more difficult than I anticipated to port the code I had written into Android Studio to produce a version of the game that would function on mobile devices. However, because I had applied the principles of encapsulation, inheritance, and polymorphism to my Java classes and functions, I was able to get the program to a partially functioning state on Android by the final due date. My first challenge in porting the project from PC to Android was addressing how to display the program on the device’s screen. Through this book, I found that constructing my Game class so it would extend Android’s Activity class would be the first step in displaying the desired output. I also applied the principle of inheritance to the Java classes I created to represent the in-game objects represented on screen. As many objects as I could manage inherited from a parent GameObject interface, which would be extended into more specific StaticGameObject and MovableGameObject subclasses, and then from those classes I extended them into specific types of objects like PlayerCharacter, Obstacle, and BonusItem. For my next software endeavor, I want to adhere to these principles more purposefully when coding, as I think that a lot of the challenges and headaches I experienced while creating this video game were self-inflicted.

If you want to try the game I made (I was so pressed for time by the end I never named it), here is a link to my Github repository. The project should be able to opened up and run from inside BlueJ or your Java IDE of choice.

Source: Learning Java by Building Android Games: Learn Java and Android from scratch by building five exciting games, 3rd Edition by John Horton

Github repository: https://github.com/MCummingsWSU/CS373-mobile-app-final-project

Screenshot of my game available at the Github link

From the blog CS@Worcester – Michael's Programming Blog by mikesprogrammingblog and used with permission of the author. All other rights reserved by the author.

First post!

Hello! I’m going to be using this blog primarily for my CS-343 course, but I’ll try and add my past projects soon, as well as maintain the blog after the course.

From the blog CS@Worcester – Michael's Programming Blog by mikesprogrammingblog and used with permission of the author. All other rights reserved by the author.