-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdventurer.cs
60 lines (53 loc) · 2.06 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
50
51
52
53
54
55
56
57
58
59
60
using System.Text;
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 <- why
// 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; }
// Add a new immutable property to the Adventurer class called ColorfulRobe. The type of this property should be Robe.
public Robe ColorfulRobe { get; }
// A constructor to make a new Adventurer object with a given name
//Add a new constructor parameter to the Adventurer class to accept a Robe and to set the ColorfulRobe property.
public Adventurer(string name, Robe adventurerRobe)
{
Name = name;
Awesomeness = 50;
ColorfulRobe = adventurerRobe;
}
// 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}";
}
public string GetDescription()
{
return $"{Name}'s robe is {ColorfulRobe.Length} inches long.";
}
}
}