Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c1bf324
Added initial file to test the save function, and added a Team object…
Bryan-Culver Sep 23, 2023
b16fe7c
created tests and basic Team class for the basis of the app
Bryan-Culver Sep 26, 2023
b52b378
committing the rest of the files changed
Bryan-Culver Sep 26, 2023
18a674f
continuing to do work on the gradle file.
Bryan-Culver Oct 3, 2023
9b65a30
made changes to gitignore
Bryan-Culver Oct 7, 2023
7db76ed
implemented the new GridBagConstraintsObject and all labels are in pl…
Bryan-Culver Apr 7, 2023
35ae6f8
Meets requirements. Still refactoring.
Bryan-Culver Apr 14, 2023
5d46db3
Customized the appearance of the window, and established a custom 'JT…
Bryan-Culver Apr 14, 2023
d522d6b
Added comments to Main.java
Bryan-Culver Sep 22, 2023
60c75e5
this is a required commit message
Bryan-Culver Sep 22, 2023
5bbca42
Added gradle, working on tests and tasks
Bryan-Culver Sep 22, 2023
a5a42df
did some work in gradle and added gradle files to .gitignore
Bryan-Culver Sep 22, 2023
18d59f8
Droped files from .gitignore
Bryan-Culver Sep 22, 2023
ba6a1b2
Just added a new contributing file, hopefully this commit is signed.
Bryan-Culver Oct 3, 2023
52f1261
updates to the Contributing document
Bryan-Culver Oct 3, 2023
2d05e90
making more changes
Bryan-Culver Oct 3, 2023
06419a2
uni
Bryan-Culver Oct 3, 2023
76e8d24
completed first draft of the CONTRIBUTING.md document
Bryan-Culver Oct 4, 2023
d204548
Made an adjustment to README and implemented a game screen view in or…
Bryan-Culver Oct 7, 2023
8a0282c
Restructured for Gradle, and improved welcome screen.
Bryan-Culver Nov 12, 2023
f3bb6dd
implemented multi-window functionality
Bryan-Culver Nov 21, 2023
dfc5be4
added model package and Game and Team classes in order to predict game
Bryan-Culver Nov 21, 2023
ef17de4
Application simulates a game. everything is crude, but we have an ini…
Bryan-Culver Nov 23, 2023
9950634
made updates to .gitignore
Bryan-Culver Nov 23, 2023
18cef18
made updates to .gitignore
Bryan-Culver Nov 23, 2023
d647ffb
Merge branch '18-simulate-a-game' of github.com:Bryan-Culver/hockeyAp…
Bryan-Culver Nov 23, 2023
7e78bd5
Merge branch '18-simulate-a-game' into branchForSigning
Bryan-Culver Nov 23, 2023
11d7a53
Merge pull request #23 from Bryan-Culver/branchForSigning
Bryan-Culver Nov 23, 2023
84180b4
Added initial file to test the save function, and added a Team object…
Bryan-Culver Sep 23, 2023
b1f67f6
committing the rest of the files changed
Bryan-Culver Sep 26, 2023
0d56a6e
continuing to do work on the gradle file.
Bryan-Culver Oct 3, 2023
c742112
Merge branch 'Create-Teams' of github.com:Bryan-Culver/hockeyApp into…
Bryan-Culver Nov 23, 2023
2b97253
These are some random updates and improvements
Bryan-Culver Mar 1, 2024
b7336ae
Merge pull request #24 from Bryan-Culver/refactoring
Bryan-Culver Mar 1, 2024
bafd1d2
I have no idea what the status of this is yet.
Bryan-Culver Oct 3, 2025
e8d7d91
added github actions file.
Bryan-Culver Oct 3, 2025
4d00e67
added Gradle Wrapper.
Bryan-Culver Oct 3, 2025
9f44bbd
make gradlew executable.
Bryan-Culver Oct 3, 2025
4e411cc
Added gradle wrapper exception to gitignore
Bryan-Culver Oct 3, 2025
d9b21fa
Add maven repository for dependencies.
Bryan-Culver Oct 3, 2025
1ac9aae
Updated dependencies
Bryan-Culver Oct 4, 2025
be14e6b
corrected usage of json builder
Bryan-Culver Oct 4, 2025
f7a7056
corrected test file
Bryan-Culver Oct 4, 2025
242d0b2
continue to fix tests
Bryan-Culver Oct 4, 2025
daaaba8
added junit to gradle
Bryan-Culver Oct 4, 2025
3f1d953
unified tests to version 5
Bryan-Culver Oct 4, 2025
8751892
removed stubs for now
Bryan-Culver Oct 4, 2025
ec2b1eb
removed more stubs
Bryan-Culver Oct 4, 2025
1f97bce
temporarilly removed all tests
Bryan-Culver Oct 4, 2025
6681db3
Merge pull request #25 from Bryan-Culver/7-save
Bryan-Culver Oct 4, 2025
64d448b
Revert "7 save"
Bryan-Culver Oct 4, 2025
feb9a63
Merge pull request #26 from Bryan-Culver/revert-25-7-save
Bryan-Culver Oct 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
### Gradle ###
.gradle
/build/
.gradle/
.metadata

# Mobile Tools for Java (J2ME)
.mtj.tmp/
Expand All @@ -30,4 +32,4 @@ hs_err_pid*
.project
.settings/
.classpath
/bin/
/bin/
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# HockeyApp
An Educational Test-Driven exercise in Object-Oriented design using Java Swing.

This project gives you the task of managing a Hockey team using Java Swing, but it is really designed to practice
object-oriented design patterns with each added feature. The associated project also is organized to help facilitate
a Test-Driven Development approach.
This project gives you the opportunity to predict the result of a Hockey game using Java Swing, but it is really
designed to practice object-oriented design patterns with each added feature. The associated project also is organized
to help facilitate a Test-Driven Development approach.

Clone it, build it, run it, and click through some of the options available as a Team Owner.
Clone it, build it, run it, and run a few games.
Then, when you understand **what** the app does, explore **how** the code is structured, and imagine new features you
would like to add using classic and modern design patterns.

Expand All @@ -23,18 +23,18 @@ Using your SSH key, enter the command `git clone [email protected]:Bryan-Culver/hoc
If you're using HTTPS still, the command is `git clone https://github.com/Bryan-Culver/hockeyApp.git` in your terminal.

## Build It

Currently, this project is a simple Java Swing project. Use your IDE to compile the program with at least JavaSE-17.
No other versions of Java have been tested at this time. As it is compiled, an executable is generated which will run
the app.
the app.

## Run It
When you run the app, you will see one Window that will display some basic amount of information about the team.
When you run the app, you will see one Window that will display inputs for the home team and away team.

As this project grows, more screens and "Views" will be required and will eventually be available.

## Contributing
There will be a "Contributing.md" file provided within this repository as soon as this project is ready to take on
contributions.
Please reference the "Contributing.md" doc provided in this repository.

You'll notice the **.gitignore** file has several file types that are specific to IDEs. Any additional files that your
editor will creat for metadata should be added to the **.gitignore** file.
editor will create for metadata should be added to the **.gitignore** file.
12 changes: 10 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
apply plugin: 'java'
apply plugin: 'eclipse'
plugins{
id 'java'
id 'eclipse'
id 'jacoco'
}

test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}
9 changes: 5 additions & 4 deletions src/main/Main.java → src/main/java/launch/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/**
* This is the Main view for the Team building Interface window.
*/
package main;
package main.java.launch;

import view.TeamBuildingView;
//import main.java.view.TeamBuildingView;
import main.java.view.GameScreenView;

/**
*
Expand All @@ -21,8 +22,8 @@ public static void main(String[] args) {
}

public static void run() {
TeamBuildingView view = new TeamBuildingView("The Fun Hockey App");
view.setVisible(true);
@SuppressWarnings("unused")
GameScreenView view = new GameScreenView("The Fun Hockey App");
}

}
70 changes: 70 additions & 0 deletions src/main/java/model/Game.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
*
*/
package main.java.model;

import java.util.concurrent.ThreadLocalRandom;

/**The Game class creates and runs a Hockey game, generating all stats that come from it.
* @author "Bryan Culver"
*
*/
public class Game {
private Team homeTeam;
private Team awayTeam;
private int scoreAway = 0;
private int scoreHome = 0;
//private boolean overtime;
private final int RANDOM_MAX = 100;
private final int RANDOM_MIN = 0;

/**Game will take two teams, play a game between them, and generate stats from the game.
* Stats are available through getters.
*
* @param homeTeam
* @param awayTeam
*/
public Game(Team awayTeam, Team homeTeam) {
this.awayTeam = awayTeam;
this.homeTeam = homeTeam;
play();
}

/**This getter provides a string of the team's location and name.
*
* @return String
*/
public String getHomeTeam() {
return homeTeam.toString();
}

public String getAwayTeam() {
return awayTeam.toString();
}

public int getScoreAway() {
return scoreAway;
}

public int getScoreHome() {
return scoreHome;
}

private void play() {
for (int period=1;period<=3;period++) {
int randomNum = ThreadLocalRandom.current().nextInt(RANDOM_MIN, RANDOM_MAX +1);
if(randomNum>60) {
scoreAway++;
}else {
scoreHome++;
}
}
}

/*public String toString() {
String result = "";
result = awayTeam.getLocation()+" "+awayTeam.getName()+" at "+homeTeam.getLocation()+" "+homeTeam.getName()+": "+scoreAway+" - "+scoreHome;
return result;
}*/

}
35 changes: 35 additions & 0 deletions src/main/java/model/Team.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
*
*/
package main.java.model;

/**
* @author "Bryan Culver"
*
*/
public class Team {
String location = "";
String name = "";

/**
* This class takes two strings and creates a simple team class.
* @param location String
* @param name String
*/
public Team(String location, String name) {
this.location = location;
this.name = name;
}

public String getName() {
return name;
}

public String getLocation() {
return location;
}

public String toString() {
return location + " " + name;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
*
*/
package util;
package main.java.util;

import java.awt.GridBagConstraints;
import java.awt.Insets;
Expand Down
87 changes: 87 additions & 0 deletions src/main/java/view/CreateTeamView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package main.java.view;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

import main.java.util.GridBagConstraintsObject;

import javax.swing.JTextArea;
import javax.swing.JPanel;
import javax.swing.JLabel;

public class CreateTeamView{
/**
*
*/
private JFrame createTeamFrame = new JFrame("Create a New Team");
private JPanel panel;

public CreateTeamView(String title) {
createTeamFrame.setTitle(title);

GridBagLayout gbl = new GridBagLayout();
panel = new JPanel(gbl);

JLabel teamNameLabel = new JLabel("Team Name");
JButton saveButton = new JButton("Save");
JButton cancelButton = new JButton("Cancel");
//int cupWins = 0; // TODO implement a get method for this.
//int standingLastYear = 12; // TODO implement a get method for this.

// Implemented a HockeyViewTextArea class to avoid repeating changes to the JTextAreas.
//HockeyViewTextArea cupWinsTA = new HockeyViewTextArea(Integer.toString(cupWins),createTeamFrame.getBackground());
//HockeyViewTextArea standingTA = new HockeyViewTextArea(Integer.toString(standingLastYear), createTeamFrame.getBackground());
//HockeyViewTextArea userNameTA = new HockeyViewTextArea("username", createTeamFrame.getBackground());
JTextArea locationTA = new JTextArea("City/State");
JTextArea teamNameTA = new JTextArea("Team Name");

GridBagConstraintsObject gbco = new GridBagConstraintsObject();
gbco.insets(15).anchor(GridBagConstraints.LINE_START).fill(GridBagConstraints.VERTICAL).ipadx(2).ipady(2);

//panel.add(new JLabel("Owner's Name"),gbco.gridx(0).gridy(0));
panel.add(new JLabel("Team's Location"), gbco.gridy(1).gridx(0));
panel.add(teamNameLabel, gbco.gridy(2).gridx(0));
//panel.add(new JLabel("Stanley Cup Wins"), gbco.gridy(3).gridx(0));
//panel.add(new JLabel("Last Year's standing"), gbco.gridy(4).gridx(0));

//panel.add(userNameTA,gbco.gridx(1).gridy(0).fill(GridBagConstraints.HORIZONTAL).weightx(0.6));
panel.add(locationTA, gbco.gridx(1).gridy(1));
panel.add(teamNameTA, gbco.gridx(1).gridy(2));
//panel.add(cupWinsTA, gbco.gridx(1).gridy(3));
//panel.add(standingTA, gbco.gridx(1).gridy(4).fill(GridBagConstraints.HORIZONTAL));

panel.add(cancelButton, gbco.gridx(0).gridy(5).anchor(GridBagConstraints.LAST_LINE_START).fill(0));
panel.add(saveButton, gbco.gridy(5).gridx(4).anchor(GridBagConstraints.LAST_LINE_END).weightx(0));

saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//Check data submitted
//Save team information submitted
@SuppressWarnings("unused")
GameScreenView welcomeView = new GameScreenView("Hockey App");
createTeamFrame.dispose();
}
});

cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@SuppressWarnings("unused")
GameScreenView welcomeView = new GameScreenView("Hockey App");
createTeamFrame.dispose();
}
});

createTeamFrame.getContentPane().add(panel);
createTeamFrame.setLocationRelativeTo(null);
createTeamFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

createTeamFrame.pack();
createTeamFrame.setVisible(true);
}
}
Loading