All Programming Concepts used in the Math Game
All Programming Concepts used in the Math Game
Description
Structural features
Figure 1: Game package’s classes in IntelliJ
Game package has 10 classes. This mainly targets the
first success criteria of my client, engaging and
teaching students.
Figure 3: Student database structure The ‘student’ table’s design is shown. It consists of
field identifiers, their respective data types, and
variable sizes. “Allow nulls” ensure new records aren’t
created in empty fields.
Figure 6: Use of CSS, JS and HTML in IntelliJ 17 HTML, 12 CSS and 6 JS files were created. HTML
provides the UI like login and menus while CSS and JS
provide technical details like bootstrap and ionicons.
1
2
Figures 6, 7 and 8: Main GUI Components
Java Swing, IntelliJ’s GUI builder, provides cross-platform compatibility because it effectively runs
with any JVM. Its components are shown in these figures:
3
GUI Components Function
JOptionPane A dialog box that identifies if the user wants to exit the application.
GamePanel Subclass of JPanel that handles the gameplay rendering and UI updates.
JFrame Window that holds other components and handles the game’s visibility.
KeyListener Manages keyboard actions in real-time, allowing users to move the bird.
JRadioButton Allows students to only select 1 option from 5 when only 1 option is correct.
JButton A clickable feature that produces an action like ensuring if the clicked button is the
right answer.
OOP framework helps maintain the coding standards and promotes reusability. Below are some
examples:
4
This constructor initialises a Bird object with default size, position, and state values. It’s suitable because it immediately
initialises every Bird parameter, which is vital for correct functionality and gamification (success criteria 1)
Inheritance: GamePanel inheriting from JPanel allows it to function as a Swing component. This permits GamePanel to
perform rendering functionalities, managing user input and layout.
5
Encapsulation: The game instance represents the game state and has a private access modifier, preventing any
outsiders’ modification.
Manages various properties within the application to improve student engagement when learning (success criteria 1) by
allowing other classes to obtain values without accessing variables, preventing unwanted changes, and allowing other
classes to update values when necessary.
Figure 12: Implementing a hierarchical composite data structure (Arraylist) As suggested by the tutor to increase application
engagement, this ArrayList stores all renderable
objects including Bird, Pipes, and the
background images for the game. This permits
the getRenders class to draw every required
element from a single location, improving
flexibility.
6
2 score arrays are being combined into 1 sorted
array, allowing the teachers to view students’
scores more easily and identify each students’
status in learning.
7
Hashmap performs caching to store the game’s
images loaded from the CDrive. This is done by
Figure 17: Use of a Hashmap in Util class mapping every image’s file path to its respective
‘Image’ object, aiding gamification by providing
graphics for game.
8
9
Figures 18, 19, 20, and 21: high score modification by adding, deleting, and searching in random access files.
RandomAccessFile is used to store and modify high scores in binary. Achieved by creating a temporary file,
making modification easier, and preventing data loss.
This improves application security by reducing the probability of unauthorised users from identifying the
password of each user, providing personalised experiences for all users. The code takes input and produces its
MD5 hash, used for encrypting the password. This aligns with success criteria 7 because encryption is provided to
passwords in login history system. The submenu is shown below:
10
Figure 23: Login History submenu, encrypted password seen in the ‘password’ column.
11
‘getStudentByUserId’ method differentiates each
student by their ID, helping to achieve client’s
success criterion. Students can see their own
performance due to their unique ID and use their
ID to login to only their account.
‘bindAchievements’ method provides a specific
achievements list for each student based on a
unique ID, correlating with success criteria
regarding incentive provision.
12
Figure 27 and 28: StudentService with complex if-else statements inside for loops.
From ‘StudentRepo’ interface, a student’s list is received by ‘bindStudentList’ method, calling stored
procedures, aligning with success criteria that allow for different menus for students and teachers.
‘getStudentByUserId’ receives specific student’s profile details using a unique StudentID by calling stored
procedures through the repository, aligning with success criteria that helps change password and other login
features. Below are the main menus for both users:
Figure 29: Student main menu screen. This is shown from a sample student.
13
Figure 30: Teacher main menu screen. This is shown from a sample teacher.
Cornell University’s Java Guidelines are used to identify the appropriate styling conventions. All code snippets shown are
written in CamelCase, and “_” isn’t used. Variable names begin with a lowercase letter. This convention followed
“Substatements of a statement or declaration should be indented”(Gries, 2017). Comments are used appropriately to identify
the function of each technique in the code without over-commenting.
14
Valid
Email
NotEmpty
Pattern
Size
Entity
Id
Table
(k) Java Standard Libraries
ArrayList
Hashmap
Arrays
List
java.awt*
Date
Duration
Objects
(l) Lombok Libraries
AllArgsConstructor
Data
ToString
JpaRepository
Repository
Procedure
Param
(m) Spring Framework Libraries
Autowired
Controller
HttpSession
Model
BindingResult
Bind.annotation.*
RestTemplate
RedirectAttributes
stereotype.Component
GetMapping
PostMapping
Service
Transactional
SpringApplication
SpringBootApplication
ApplicationContext
ComponentScan
Configuration
EnableJpaRepositories
EnableTransactionManagement
(n) Security Libraries
MessageDigest
NoSuchAlgorithmException
15
(o) Login and Sign In Pages with Code
Figure 33: Giving specific colors, sizes, and text fonts to the buttons
Figure 34: Adding space between form groups, and changing label and input styles
16
Figure 35: Annotated HTML code to demonstrate validations.
Figure 36: Annotated Java code with series of if statements to store user IP address and redirect users to their respective menu.
Figure 37: Stored Procedure to provide commands that help store the login details for each user.
17
Figure 38: Annotated Sign-Up page.
Figure 39: Annotated Java code to validate user sign-up details and redirect users to their respective menus.
18
Figure 40: Annotated JS code that ensures complex validations by using length, presence, and format checks.
Figure 41: Annotated JS code that ensures complex validations by using length, presence, and format checks.
19
(p) Student Play Game submenu
20
(q) UML Diagram
Figure 44: UML diagram showing the main functionalities of the product
Work Cited
Gries, D. (2017). cs.cornell. Java Code Style Guidelines. Retrieved August 29, 2024, from
https://www.cs.cornell.edu/courses/JavaAndDS/ JavaStyle.html#CamelCase
https://www.w3schools.com/sql/
21
https://learn.microsoft.com/en-us/sql/sql-server/tutorials-for-sql-server-2016?view=sql-serv
er-ver16
https://docs.oracle.com/javase/tutorial/uiswing/index.html
https://www.w3schools.com/java/java_arraylist.asp
https://www.geeksforgeeks.org/java-util-hashmap-in-java-with-examples/
https://learn.microsoft.com/en-us/sql/relational-databases/stored-procedures/create-a-stor
ed-procedure?view=sql-server-ver16
Free Learning Platform for Better Future. (n.d.). Spring Tutorial. javatpoint.
https://javatpoint.com/spring-tutorial
https://eclipse-ee4j.github.io/jakartaee-tutorial/
https://www.geeksforgeeks.org/md5-hash-in-java/
https://www.w3schools.com/java/java_try_catch.asp
geeksforgeeks.
https://www.geeksforgeeks.org/java-io-randomaccessfile-class-method-set-1/
Kumar, P. (2024, October 4). Different ways of Reading a text file in Java. geeksforgeeks.
https://www.geeksforgeeks.org/different-ways-reading-text-file-java/
https://www.instructables.com/Java-Game-Programming-Tutorial-Flappy-Bird-Redux/
Jeong, S. (2022, May 12). Implement Password change in SpringBoot using JPA. medium.
22
https://medium.com/@seonggil/implement-password-change-in-springboot-using-jpa-fbc46
f037ac3
https://www.geeksforgeeks.org/implementing-edit-profile-data-functionality-in-social-media-
android-app/
https://www.pragmaticcoding.ca/javafx/elements/task-progress
https://openart.ai/community/VAhDFl5YmWvMusFoLumQ
23