-
Notifications
You must be signed in to change notification settings - Fork 0
/
Adventurer.cs
49 lines (44 loc) · 1.56 KB
/
Adventurer.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
namespace Quest
{
// An instance of the Adventurer class is an object that will undergo some challenges
public class Adventurer
{
// This is an "immutable" property. It only has a "get".
// The only place the Name can be set is in the Adventurer constructor
// Note: the constructor is defined below.
public string Name { get; }
// This is a mutable property it has a "get" and a "set"
// So it can be read and changed by any code in the application
public int Awesomeness { get; set; }
// A constructor to make a new Adventurer object with a given name
public Adventurer(string name)
{
Name = name;
Awesomeness = 50;
}
// This method returns a string that describes the Adventurer's status
// Note one way to describe what this method does is:
// it transforms the Awesomeness integer into a status string
public string GetAdventurerStatus()
{
string status = "okay";
if (Awesomeness >= 75)
{
status = "great";
}
else if (Awesomeness < 25 && Awesomeness >= 10)
{
status = "not so good";
}
else if (Awesomeness < 10 && Awesomeness > 0)
{
status = "barely hanging on";
}
else if (Awesomeness <= 0)
{
status = "not gonna make it";
}
return $"Adventurer, {Name}, is {status}";
}
}
}