})(window,document,'script','dataLayer','GTM-55V2NQQ6');

Mypacman Java

325 words | 2 page(s)

The program is organized into a java class. The java class “MyPacman” has been used here as a public class making all the codes within the class to be accessible from other parts of the program without restrictions. Unlike in many programs, no package has been used for this case.

The program has ensured the provision of linear relationships among the elements that have been represented by using arrays (Alur et al., 2003). The expected outputs are printed in an array format. Besides, the array that has been extensively used to hold states in the program.

puzzles puzzles
Your 20% discount here.

Use your promo and get a custom paper on
"Mypacman Java".

Order Now
Promocode: custom20

The commands in the main program i.e. public static void main(String args[]) have been used to control and regulate the behaviour of the program (Yener & Theedom, 2015). The line int curRow = 0, curCol = 0, noOfEats = 0, noOfCommands = 0; has been used to initialize the values of curRow, that of curCol, noOfEats and that of noOfCommands all to be zero. This shows that their initial values are at zero. The user is then allowed to type in the number of rows and columns he requires. The line “for(int i = 0; i < rows; i++)” and “for(int j = 0; j < columns; j++)” have been used in the program to control or regulate how the array values for rows and columns increments, with j being used for the columns and i for the rows. The Pacman state has been maintained in this program by the use of loop statements like while statement and the case statements (Wright, 2015). It can be learned that a game is just a combination of loop statements, when a condition is met as written in the program the solution is found, otherwise the loop continues rotating.

    References
  • Alur, D., Crupi, J., & Malks, D. (2003). Core J2EE patterns: Best practices and design strategies. Upper Saddle River, NJ: Prentice-Hall PTR.
  • Wright, T. (2015). Fundamental 2D game programming with Java. Boston, MA: Cengage Learning PTR.
  • Yener, M., & Theedom, A. (2015). Professional Java EE design patterns. Indianapolis, Ind: Wiley.

puzzles puzzles
Attract Only the Top Grades

Have a team of vetted experts take you to the top, with professionally written papers in every area of study.

Order Now