mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Created boat class & tests
This commit is contained in:
@@ -4,6 +4,6 @@ public class App
|
|||||||
{
|
{
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
{
|
{
|
||||||
System.out.println( "Welcome to SENG302" );
|
System.out.println("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package seng302;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Represents a boat in the race.
|
||||||
|
|
||||||
|
@param teamName The name of the team sailing the boat
|
||||||
|
*/
|
||||||
|
public class Boat
|
||||||
|
{
|
||||||
|
// The name of the team, this is also the name of the boat
|
||||||
|
private String teamName = null;
|
||||||
|
|
||||||
|
public Boat(String teamName) {
|
||||||
|
this.teamName = teamName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns the name of the team sailing the boat
|
||||||
|
@returns The name of the team
|
||||||
|
*/
|
||||||
|
public String getTeamName(){
|
||||||
|
return this.teamName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sets the name of the team sailing the boat
|
||||||
|
@param teamName The name of the team
|
||||||
|
*/
|
||||||
|
public void setTeamName(String teamName){
|
||||||
|
this.teamName = teamName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package seng302;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test for the Team class.
|
||||||
|
*/
|
||||||
|
public class BoatTest
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testBoatCreation()
|
||||||
|
{
|
||||||
|
Boat boat1 = new Boat("Team 1");
|
||||||
|
assertEquals(boat1.getTeamName(), "Team 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChangeTeamName()
|
||||||
|
{
|
||||||
|
Boat boat1 = new Boat("Team 1");
|
||||||
|
boat1.setTeamName("Team 2");
|
||||||
|
assertEquals(boat1.getTeamName(), "Team 2");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user