Monday, March 2, 2015

Head First Java: Chapter 5

Battleship Game:

        In this chapter we were required to build a video game. This allowed us to test and apply our knowledge in a real application. The game that had to be build was battleship, and the in this chapter I learned the steps and process of building this game. Instead of following the book step by step I implemented a few of my own methods and ideas (explained below).

One thing I did differently was instead of using the Game Helper class from the book I used the Scanner class to get and use User input. Another thing I did differently was instead of the Math class to get a random location I used the Random Class to generate a random number for the location of the dot com. 



Other learning points:

Casting primitives : This allows you to convert between different primitive types. For example this allows you to convert 7.14 which is a double to 7 which is an int.

Another learning point was converting a string to an integer using Interger.parseInt("Numerical String value)

No comments:

Post a Comment