-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathView.cs
121 lines (105 loc) · 3.88 KB
/
View.cs
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
using System;
namespace DepthCharge
{
/// <summary>
/// Contains methods for displaying information to the user.
/// </summary>
static class View
{
public static void ShowBanner()
{
Console.WriteLine(" DEPTH CHARGE");
Console.WriteLine(" CREATIVE COMPUTING MORRISTOWN, NEW JERSEY");
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
}
public static void ShowInstructions(int maximumGuesses)
{
Console.WriteLine("YOU ARE THE CAPTAIN OF THE DESTROYER USS COMPUTER");
Console.WriteLine("AN ENEMY SUB HAS BEEN CAUSING YOU TROUBLE. YOUR");
Console.WriteLine($"MISSION IS TO DESTROY IT. YOU HAVE {maximumGuesses} SHOTS.");
Console.WriteLine("SPECIFY DEPTH CHARGE EXPLOSION POINT WITH A");
Console.WriteLine("TRIO OF NUMBERS -- THE FIRST TWO ARE THE");
Console.WriteLine("SURFACE COORDINATES; THE THIRD IS THE DEPTH.");
Console.WriteLine();
}
public static void ShowStartGame()
{
Console.WriteLine("GOOD LUCK !");
Console.WriteLine();
}
public static void ShowGuessPlacement((int x, int y, int depth) actual, (int x, int y, int depth) guess)
{
Console.Write("SONAR REPORTS SHOT WAS ");
if (guess.y > actual.y)
Console.Write("NORTH");
if (guess.y < actual.y)
Console.Write("SOUTH");
if (guess.x > actual.x)
Console.Write("EAST");
if (guess.x < actual.x)
Console.Write("WEST");
if (guess.y != actual.y || guess.x != actual.y)
Console.Write(" AND");
if (guess.depth > actual.depth)
Console.Write (" TOO LOW.");
if (guess.depth < actual.depth)
Console.Write(" TOO HIGH.");
if (guess.depth == actual.depth)
Console.Write(" DEPTH OK.");
Console.WriteLine();
}
public static void ShowGameResult((int x, int y, int depth) submarineLocation, (int x, int y, int depth) finalGuess, int trailNumber)
{
Console.WriteLine();
if (submarineLocation == finalGuess)
{
Console.WriteLine($"B O O M ! ! YOU FOUND IT IN {trailNumber} TRIES!");
}
else
{
Console.WriteLine("YOU HAVE BEEN TORPEDOED! ABANDON SHIP!");
Console.WriteLine($"THE SUBMARINE WAS AT {submarineLocation.x}, {submarineLocation.y}, {submarineLocation.depth}");
}
}
public static void ShowFarewell()
{
Console.WriteLine ("OK. HOPE YOU ENJOYED YOURSELF.");
}
public static void ShowInvalidNumber()
{
Console.WriteLine("PLEASE ENTER A NUMBER");
}
public static void ShowInvalidDimension()
{
Console.WriteLine("PLEASE ENTER A VALID DIMENSION");
}
public static void ShowTooFewCoordinates()
{
Console.WriteLine("TOO FEW COORDINATES");
}
public static void ShowTooManyCoordinates()
{
Console.WriteLine("TOO MANY COORDINATES");
}
public static void ShowInvalidYesOrNo()
{
Console.WriteLine("PLEASE ENTER Y OR N");
}
public static void PromptDimension()
{
Console.Write("DIMENSION OF SEARCH AREA? ");
}
public static void PromptGuess(int trailNumber)
{
Console.WriteLine();
Console.Write($"TRIAL #{trailNumber}? ");
}
public static void PromptPlayAgain()
{
Console.WriteLine();
Console.Write("ANOTHER GAME (Y OR N)? ");
}
}
}