-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShip.java
executable file
·59 lines (52 loc) · 1.01 KB
/
Ship.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Michael Zetune, Brett Mendenhall
* 3/31/16
* Gallatin 2nd
*/
public class Ship {
private ShipType type;
/**
* Constructs a ship object with a ship type
* @param type the type of the ship
*/
public Ship(ShipType type)
{
this.type = type;
}
/**
* Creates a new ship enum to distinguish ship type
*/
public enum ShipType
{
AIRCRAFT_CARRIER, BATTLESHIP, SUBMARINE, DESTROYER, PATROL_BOAT
}
/**
* getShipType gets a ship's type
* @return the ship's type
*/
public ShipType getShipType()
{
return type;
}
/**
* getSize gets the ship type's size
* @return the size of the integer size of a ship's type
*/
public int getSize()
{
switch(type)
{
case AIRCRAFT_CARRIER:
return 5;
case BATTLESHIP:
return 4;
case SUBMARINE:
return 3;
case DESTROYER:
return 3;
case PATROL_BOAT:
return 2;
}
return -1;
}
}