Skip to content

Commit 5edb778

Browse files
committed
Improving species solution.
1 parent 2699b65 commit 5edb778

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

source/code/projects/Species/Species/Bat.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
class Bat : Mammal
44
{
55
private double flightSpeed;
6+
/*
7+
* Having a property for the
8+
* flightSpeed attribute was
9+
* not required per the UML
10+
* diagram, but it was not
11+
* disallowed either.
12+
* We use this approach here
13+
* to make the code more
14+
* modular.
15+
*/
616
public double FlightSpeed
717
{
818
get { return flightSpeed; }
@@ -41,7 +51,8 @@ double flightSpeedP
4151
"Your object was created, but according to https://www.auburn.edu/cosam/faculty/biology/hood/lab/documents/Kunz.et.al.2010.LactationChapter.pdf, bats have either 2 or 4 mammary glands."
4252
);
4353
}
44-
flightSpeed = flightSpeedP;
54+
// Note that we use our property below.
55+
FlightSpeed = flightSpeedP;
4556
}
4657

4758
public override string ToString()
@@ -50,7 +61,7 @@ public override string ToString()
5061
+ String.Format(
5162
"| {0,-20} | {1,-40}\n",
5263
"Flight speed",
53-
flightSpeed
64+
FlightSpeed
5465
)
5566
+ String.Format(
5667
"| {0,-20} | {1,-40}\n",

source/code/projects/Species/Species/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static void Main()
136136
}
137137
try
138138
{
139-
Bat test4 = new Bat("LC", -10, null, 0, 12);
139+
Bat test4 = new Bat("LC", 10, "https://en.wikipedia.org/wiki/whatever", 2, -10);
140140
}
141141
catch (Exception e)
142142
{
@@ -156,5 +156,8 @@ static void Main()
156156
{
157157
Console.WriteLine(e.Message);
158158
}
159+
// For the bonus on the url, consider testing with
160+
// https://https://aubert.codeberg.page/.wikipedia.org/wiki/scam/
161+
// If this string is accepted, consider revising your code!
159162
}
160163
}

0 commit comments

Comments
 (0)