diff --git a/.gitignore b/.gitignore index dff7eaf..6590649 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ ### Gradle ### .gradle /build/ +.gradle/ +.metadata # Mobile Tools for Java (J2ME) .mtj.tmp/ @@ -30,4 +32,4 @@ hs_err_pid* .project .settings/ .classpath -/bin/ +/bin/ \ No newline at end of file diff --git a/README.md b/README.md index 333a19e..9c4add1 100644 --- a/README.md +++ b/README.md @@ -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. @@ -23,18 +23,18 @@ Using your SSH key, enter the command `git clone git@github.com: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. \ No newline at end of file +editor will create for metadata should be added to the **.gitignore** file. \ No newline at end of file diff --git a/build.gradle b/build.gradle index e2145c1..7721093 100644 --- a/build.gradle +++ b/build.gradle @@ -1,2 +1,10 @@ -apply plugin: 'java' -apply plugin: 'eclipse' \ No newline at end of file +plugins{ + id 'java' + id 'eclipse' + id 'jacoco' +} + +test { + useJUnitPlatform() + finalizedBy jacocoTestReport +} \ No newline at end of file diff --git a/src/main/Main.java b/src/main/java/launch/Main.java similarity index 60% rename from src/main/Main.java rename to src/main/java/launch/Main.java index e1ccb6e..295c325 100644 --- a/src/main/Main.java +++ b/src/main/java/launch/Main.java @@ -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; /** * @@ -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"); } } \ No newline at end of file diff --git a/src/main/java/model/Game.java b/src/main/java/model/Game.java new file mode 100644 index 0000000..34f2a3b --- /dev/null +++ b/src/main/java/model/Game.java @@ -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; + }*/ + +} diff --git a/src/main/java/model/Team.java b/src/main/java/model/Team.java new file mode 100644 index 0000000..f437752 --- /dev/null +++ b/src/main/java/model/Team.java @@ -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; + } +} diff --git a/src/util/GridBagConstraintsObject.java b/src/main/java/util/GridBagConstraintsObject.java similarity index 99% rename from src/util/GridBagConstraintsObject.java rename to src/main/java/util/GridBagConstraintsObject.java index 02f76a0..3b0b212 100644 --- a/src/util/GridBagConstraintsObject.java +++ b/src/main/java/util/GridBagConstraintsObject.java @@ -1,7 +1,7 @@ /** * */ -package util; +package main.java.util; import java.awt.GridBagConstraints; import java.awt.Insets; diff --git a/src/main/java/view/CreateTeamView.java b/src/main/java/view/CreateTeamView.java new file mode 100644 index 0000000..b90f6f1 --- /dev/null +++ b/src/main/java/view/CreateTeamView.java @@ -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); + } +} \ No newline at end of file diff --git a/src/main/java/view/GameScreenView.java b/src/main/java/view/GameScreenView.java new file mode 100644 index 0000000..d6bb91b --- /dev/null +++ b/src/main/java/view/GameScreenView.java @@ -0,0 +1,120 @@ +/** + * + */ +package main.java.view; + +import java.awt.GridBagConstraints; + +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; // TODO: transition from Vector to ArrayList - bottleneck: JComboBox. + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JSpinner; +import javax.swing.SpinnerListModel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.JButton; + +import main.java.util.GridBagConstraintsObject; +import main.java.model.Game; +import main.java.model.Team; + +/** + * @author Bryan Culver + * @version 7 October 2023 + */ +public class GameScreenView{ + + JFrame welcomeView = new JFrame("Hockey App"); + ArrayList awayTeamsList; + ArrayList homeTeamsList; + JButton runButton; + HockeyViewTextArea results= new HockeyViewTextArea("The winner is...", welcomeView.getBackground()); + JSpinner homeTeamSelection; + JSpinner awayTeamSelection; + public GameScreenView(String title) { + welcomeView.setTitle(title); + GridBagLayout gbl = new GridBagLayout(); + JPanel panel = new JPanel(gbl); + runButton = new JButton("Run Game Prediction"); + JButton deleteButton = new JButton("Delete Team"); + JButton editButton = new JButton("Edit Team"); + JButton newButton = new JButton("New Team"); + + newButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + @SuppressWarnings("unused") + CreateTeamView newTeamView = new CreateTeamView("Create a New Team"); + welcomeView.dispose(); + } + }); + + runButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Team homeSelect = (Team) homeTeamSelection.getValue(); + Team awaySelect = (Team) awayTeamSelection.getValue(); + String matchupResults = ""; + Game matchup = new Game(homeSelect, awaySelect); + matchupResults = matchup.getAwayTeam()+" at "+matchup.getHomeTeam()+": "+matchup.getScoreAway()+" - "+matchup.getScoreHome(); + results.setText(matchupResults); + } + }); + + HockeyViewTextArea HomeTeamLabel = new HockeyViewTextArea("Home Team", welcomeView.getBackground()); + HockeyViewTextArea AwayTeamLabel = new HockeyViewTextArea("Away Team", welcomeView.getBackground()); + + homeTeamsList = new ArrayList(); + homeTeamsList.add(new Team("Detroit", "Red Wings")); + homeTeamsList.add(new Team("Chicago", "Black Hawks")); + homeTeamsList.add(new Team("New York", "Rangers")); + + awayTeamsList = new ArrayList<>(); + awayTeamsList.add(new Team("Detroit", "Red Wings")); + awayTeamsList.add(new Team("Chicago", "Black Hawks")); + awayTeamsList.add(new Team("New York", "Rangers")); + + SpinnerListModel homeSpinnerModel = new SpinnerListModel(homeTeamsList); + homeTeamSelection = new JSpinner(homeSpinnerModel); + homeTeamSelection.setName("Home"); + SpinnerListModel awaySpinnerModel = new SpinnerListModel(awayTeamsList); + awayTeamSelection = new JSpinner(awaySpinnerModel); + awayTeamSelection.setName("Away"); + + homeTeamSelection.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + // TODO Auto-generated method stub + } + }); + awayTeamSelection.addChangeListener(new ChangeListener(){ + public void stateChanged(ChangeEvent e) { + // away team actions. + } + }); + + GridBagConstraintsObject gbco = new GridBagConstraintsObject(); + gbco.insets(15).anchor(GridBagConstraints.LINE_START).fill(GridBagConstraints.VERTICAL).ipadx(2).ipady(2); + panel.add(HomeTeamLabel, gbco.gridx(0).gridy(0)); + panel.add(AwayTeamLabel, gbco.gridx(1)); + panel.add(homeTeamSelection, gbco.gridx(0).gridy(1)); + panel.add(awayTeamSelection, gbco.gridx(1)); + panel.add(runButton, gbco.gridy(3).anchor(GridBagConstraints.CENTER)); + panel.add(newButton, gbco.gridx(0).anchor(GridBagConstraints.WEST)); + panel.add(editButton, gbco.gridy(4)); + panel.add(deleteButton, gbco.gridy(5)); + + panel.add(results, gbco.gridy(6).anchor(GridBagConstraints.CENTER)); + + welcomeView.getContentPane().add(panel); + welcomeView.setLocationRelativeTo(null); + welcomeView.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + welcomeView.pack(); + welcomeView.setVisible(true); + + } +} diff --git a/src/view/HockeyViewTextArea.java b/src/main/java/view/HockeyViewTextArea.java similarity index 96% rename from src/view/HockeyViewTextArea.java rename to src/main/java/view/HockeyViewTextArea.java index e1e906d..03b09db 100644 --- a/src/view/HockeyViewTextArea.java +++ b/src/main/java/view/HockeyViewTextArea.java @@ -1,7 +1,7 @@ /** * */ -package view; +package main.java.view; import java.awt.Color; diff --git a/src/test/CreateTeamTest.java b/src/test/CreateTeamTest.java deleted file mode 100644 index 4cc9c37..0000000 --- a/src/test/CreateTeamTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/**First Testing class - * - * This class is an example of where the testing classes should be kept and how they should - * be maintained. - * - * This class will eventually be overwritten with the first actual test class once testing - * is required. UI elements will not be tested in this project and should be grouped with - * the "View" package maintaining minimal dependency between the model and controller and - * the "View" package. - * - * @version 31 March 2023 - * @author Bryan Culver - */ -package test; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - - -/** - * @author "Bryan Culver" - * - */ -class CreateTeamTest { - - - /** - * @throws java.lang.Exception - */ - @BeforeAll - static void setUpBeforeClass() throws Exception { - //view = new TeamBuildingView("Test Build"); - } - - /** - * @throws java.lang.Exception - */ - @AfterAll - static void tearDownAfterClass() throws Exception { - - } - - /** - * @throws java.lang.Exception - */ - @BeforeEach - void setUp() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @AfterEach - void tearDown() throws Exception { - } - - @Test - void test() { - fail("Not yet implemented"); - } - -} diff --git a/src/test/GridBagConstraintsObjectTest.java b/src/test/GridBagConstraintsObjectTest.java deleted file mode 100644 index 6f6be4a..0000000 --- a/src/test/GridBagConstraintsObjectTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * - */ -package test; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.awt.GridBagConstraints; -import java.awt.Insets; - -import util.GridBagConstraintsObject; - - -/** Test Class for the util.GridBag - * @author Bryan Culver - * @version 4 April 2023 - */ -class GridBagConstraintsObjectTest { - static GridBagConstraintsObject gbco; - final static int testInt = 42; - - /** - * @throws java.lang.Exception - */ - @BeforeAll - static void setUpBeforeClass() throws Exception { - - } - - /** - * @throws java.lang.Exception - */ - @AfterAll - static void tearDownAfterClass() throws Exception { - } - - /**Each test will be set up with a new, clean gbco object. - * @throws java.lang.Exception - */ - @BeforeEach - void setUp() throws Exception { - gbco = new GridBagConstraintsObject(); - } - - /** - * @throws java.lang.Exception - */ - @AfterEach - void tearDown() throws Exception { - - } - - /** - * Test method for {@link util.GridBagConstraintsObject#GridBagConstraintsObject()}. - */ - @Test - void testGridBagConstraintsObject() { - assertTrue(gbco instanceof GridBagConstraints); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#gridx(int)}. - */ - @Test - void testGridx() { - gbco.gridx(testInt); - assertEquals(gbco.gridx, testInt); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#gridy(int)}. - */ - @Test - void testGridy() { - gbco.gridy(testInt); - assertEquals(gbco.gridy, testInt); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#insets(int)}. - */ - @Test - void testInsets() { - gbco.insets(testInt); - Insets testInsets = new Insets(testInt, testInt, testInt, testInt); - assertEquals(gbco.insets, testInsets ); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#anchor(int, int, int, int)}. - */ - @Test - void testIndivInsets() { - gbco.insets(2, 3, 5, 7); - Insets testIndivInsets = new Insets(2,3,5,7); - assertEquals(gbco.insets, testIndivInsets); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#anchor(int)}. - */ - @Test - void testAnchor() { - gbco.anchor(GridBagConstraints.FIRST_LINE_END); - assertEquals(gbco.anchor, GridBagConstraints.FIRST_LINE_END); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#fill(int)}. - */ - @Test - void testFill() { - gbco.fill(GridBagConstraints.BOTH); - assertEquals(gbco.fill, GridBagConstraints.BOTH); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#gridheight(int)}. - */ - @Test - void testGridHeight() { - gbco.gridheight(11); - assertEquals(gbco.gridheight, 11); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#gridwidth(int)}. - */ - @Test - void testGridWidth() { - gbco.gridwidth(17); - assertEquals(gbco.gridwidth, 17); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#ipadx(int)}. - */ - @Test - void testIPadX() { - gbco.ipadx(testInt); - assertEquals(gbco.ipadx, testInt); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#ipady(int)}. - */ - @Test - void testIPadY() { - gbco.ipady(testInt); - assertEquals(gbco.ipady, testInt); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#weightx(double)}. - */ - @Test - void testWeightX() { - gbco.weightx(0.5); - assertEquals(gbco.weightx, 0.5); - } - - /** - * Test method for {@link util.GridBagConstraintsObject#weighty(double)}. - */ - @Test - void testWeightY() { - gbco.weighty(0.5); - assertEquals(gbco.weighty, 0.5); - } - -} diff --git a/src/test/java/model/GameTest.java b/src/test/java/model/GameTest.java new file mode 100644 index 0000000..532f6b8 --- /dev/null +++ b/src/test/java/model/GameTest.java @@ -0,0 +1,31 @@ +/** + * + */ +package test.java.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import main.java.model.Game; +import main.java.model.Team; + +/**Class to test the function of the Game class + * @author "Bryan Culver" + * @version 2024.02.23 + */ +public class GameTest { + + /** + * run a test on the game constructor and confirm that the total score is 3 + * (Based on current game logic.) + */ + @Test + public void constructGameTest() { + Team stubTeam1 = new Team("StubLocation","StubName"); + Team stubTeam2 = new Team("Stub2Location","Stub2Name"); + Game testGame1 = new Game(stubTeam1, stubTeam2); + assertEquals(3, testGame1.getScoreAway() + testGame1.getScoreHome(), "Total score is not equal to 3"); + assertEquals("StubLocation StubName", testGame1.getAwayTeam(),"Away team's name is wrong"); + assertEquals("Stub2Location Stub2Name", testGame1.getHomeTeam(),"Home team's name is wrong"); + } +} diff --git a/src/test/java/model/TeamTest.java b/src/test/java/model/TeamTest.java new file mode 100644 index 0000000..8b5f303 --- /dev/null +++ b/src/test/java/model/TeamTest.java @@ -0,0 +1,48 @@ +/**First Testing class + * + * This class is an example of where the testing classes should be kept and how they should + * be maintained. + * + * This class will eventually be overwritten with the first actual test class once testing + * is required. UI elements will not be tested in this project and should be grouped with + * the "View" package maintaining minimal dependency between the model and controller and + * the "View" package. + * + * @version 31 March 2023 + * @author Bryan Culver + */ +package test.java.model; + +import static org.junit.Assert.assertEquals; + +//import org.junit.jupiter.api.AfterAll; +//import org.junit.jupiter.api.AfterEach; +//import org.junit.jupiter.api.BeforeAll; +//import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.*; + +import main.java.model.*; + + +/**Testing the Team class + * @author "Bryan Culver" + * @version 2024.02.23 + */ +public class TeamTest { + Team teamTestA; + Team teamTestB; + + @Test + public void testTeamCreation() { + Team teamTestA = new Team("Chicago", "Black Hawks"); +// assert teamTestA.getLocation().equals("Chicago"); +// assert teamTestA.getName().equals("Black Hawks"); +// Team teamTestB = new Team("Detroit", "Red_Wings"); +// assert teamTestB.getLocation().equals("Detroit"); +// assert teamTestB.getName().equals("Red_Wings"); + assertEquals("","Chicago",teamTestA.getLocation()); + assertEquals("","Black Hawks",teamTestA.getName()); + // toString is tested in GameTest + } + +} diff --git a/src/view/TeamBuildingView.java b/src/view/TeamBuildingView.java deleted file mode 100644 index bb5052b..0000000 --- a/src/view/TeamBuildingView.java +++ /dev/null @@ -1,68 +0,0 @@ -package view; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JFrame; - -import util.GridBagConstraintsObject; - -import javax.swing.JPanel; -import javax.swing.JLabel; - -public class TeamBuildingView extends JFrame{ - /** - * - */ - private static final long serialVersionUID = 1L; - private JPanel panel; - private ActionListener saveListener; // TODO Implement listener class in main package. - - public TeamBuildingView(String title) { - super(title); - - GridBagLayout gbl = new GridBagLayout(); - panel = new JPanel(gbl); - - JLabel teamTitleLabel = new JLabel("Team Title"); - JButton saveButton = new JButton("Save"); - JButton editButton = new JButton("Edit"); - 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),this.getBackground()); - HockeyViewTextArea standingTA = new HockeyViewTextArea(Integer.toString(standingLastYear), this.getBackground()); - HockeyViewTextArea userNameTA = new HockeyViewTextArea("username", this.getBackground()); - HockeyViewTextArea locationTA = new HockeyViewTextArea("City, State", this.getBackground()); - HockeyViewTextArea teamNameTA = new HockeyViewTextArea("Team Name", this.getBackground()); - - 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(teamTitleLabel, 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(editButton, 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(saveListener); // TODO Implement listener class in main package - - this.getContentPane().add(panel); - this.setLocationRelativeTo(null); - this.setDefaultCloseOperation(EXIT_ON_CLOSE); - - this.pack(); - } -} \ No newline at end of file