Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
3
3XA3 Lab 3 Group 7
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mike Li
3XA3 Lab 3 Group 7
Commits
68fd3207
Commit
68fd3207
authored
3 years ago
by
Mike Li
Browse files
Options
Downloads
Patches
Plain Diff
Finished doxygen comments
parent
98318ac4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/KeyboardListener.java
+14
-0
14 additions, 0 deletions
src/KeyboardListener.java
src/SquareData.java
+20
-0
20 additions, 0 deletions
src/SquareData.java
src/SquarePanel.java
+19
-0
19 additions, 0 deletions
src/SquarePanel.java
with
53 additions
and
0 deletions
src/KeyboardListener.java
+
14
−
0
View file @
68fd3207
/**
* Authors: Mike Li, Jasper Leung, Sanjula Ganepola, Ahmed Al Koasmh
* Revised: March 29th, 2021
*
* Description: KeyboardListener class
*/
import
java.awt.event.KeyAdapter
;
import
java.awt.event.KeyEvent
;
/**
* @brief A class that handles keyboard inputs
*/
public
class
KeyboardListener
extends
KeyAdapter
{
/**
* @brief Handles keyboard input behavior
* @param e The key that is pressed by the user
*/
public
void
keyPressed
(
KeyEvent
e
)
{
switch
(
e
.
getKeyCode
())
{
...
...
This diff is collapsed.
Click to expand it.
src/SquareData.java
+
20
−
0
View file @
68fd3207
/**
* Authors: Mike Li, Jasper Leung, Sanjula Ganepola, Ahmed Al Koasmh
* Revised: March 29th, 2021
*
* Description: SquareData class
*/
import
java.util.ArrayList
;
import
java.awt.Color
;
/**
* @brief A class that holds the data of a square on the grid
*/
public
class
SquareData
{
//ArrayList that'll contain the colors
ArrayList
<
Color
>
colors
=
new
ArrayList
<
Color
>();
int
currentColor
;
//2: empty , 1: food, 0: snake
SquarePanel
square
;
/**
* @brief Initializes a SquareData object
* @param col A color that the square is set to
*/
public
SquareData
(
int
col
){
//Lets add the color to the arrayList
...
...
@@ -28,6 +43,11 @@ public class SquareData {
currentColor
=
col
;
square
=
new
SquarePanel
(
colors
.
get
(
currentColor
));
}
/**
* @brief Changes the color of the square
* @param c The color the square is to be changed to
*/
public
void
lightMeUp
(
int
c
){
square
.
changeColor
(
colors
.
get
(
c
));
}
...
...
This diff is collapsed.
Click to expand it.
src/SquarePanel.java
+
19
−
0
View file @
68fd3207
/**
* Authors: Mike Li, Jasper Leung, Sanjula Ganepola, Ahmed Al Koasmh
* Revised: March 29th, 2021
*
* Description: SquarePanel class
*/
import
java.awt.Color
;
import
javax.swing.JPanel
;
/**
* @brief A class that provides an individual square on a grid
* @details Each square has a color that can be changed
*/
public
class
SquarePanel
extends
JPanel
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* @brief Initializes a SquarePanel object
* @param d A color that the square is set to
*/
public
SquarePanel
(
Color
d
){
this
.
setBackground
(
d
);
}
/**
* @brief Changes the color of the square
* @param d The color the square is to be changed to
*/
public
void
changeColor
(
Color
d
){
this
.
setBackground
(
d
);
this
.
repaint
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment