diff --git a/CST126SRS03/CST126SRS03.vcxproj b/CST126SRS03/CST126SRS03.vcxproj index 82fc99d..a7564a4 100644 --- a/CST126SRS03/CST126SRS03.vcxproj +++ b/CST126SRS03/CST126SRS03.vcxproj @@ -169,6 +169,9 @@ Create + + + diff --git a/CST126SRS03/CST126SRS03.vcxproj.filters b/CST126SRS03/CST126SRS03.vcxproj.filters index b776bfa..ef7f008 100644 --- a/CST126SRS03/CST126SRS03.vcxproj.filters +++ b/CST126SRS03/CST126SRS03.vcxproj.filters @@ -57,4 +57,7 @@ Source Files + + + \ No newline at end of file diff --git a/CST126SRS03/elephant.cpp b/CST126SRS03/elephant.cpp index a54cb5c..128d4c7 100644 --- a/CST126SRS03/elephant.cpp +++ b/CST126SRS03/elephant.cpp @@ -1,3 +1,118 @@ #include "stdafx.h" #include "elephant.h" +void Elephant::tag(GPS& gps) +{ + setGps(gps); +} + +void Elephant::findHerd() +{ + bool herdfound = false; + + while (!herdfound) + { + int hortonHearsaWho = listen(); + + switch (hortonHearsaWho) + { + case (0): + turn(Turn::kForward); + break; + case (270): + turn(Turn::kLeft); + break; + case (90): + turn(Turn::kRight); + break; + } + + + auto toHortonsLeft = look(Turn::kLeft); + auto toHortonsFront = look(Turn::kForward); + auto toHortonsRight = look(Turn::kRight); + + //look based on 270,0, 90 and if there is no ob + + if (toHortonsLeft != Preserve::Feature::kUnknown) + { + switch (toHortonsLeft) + { + case Preserve::Feature::kUnknown: + break; + case Preserve::Feature::kHerd: + herdfound = true; + case Preserve::Feature::kDirt: + move(); + //findHerd(); + break; + case Preserve::Feature::kRock: + break; + case Preserve::Feature::kBrush: + break; + case Preserve::Feature::kGrass: + move(); + eat(); + break; + case Preserve::Feature::kWater: + move(); + drink(); + break; + } + } + + switch (toHortonsFront) + { + case Preserve::Feature::kUnknown: + break; + case Preserve::Feature::kHerd: + herdfound = true; + break; + case Preserve::Feature::kDirt: + move(); + findHerd(); + break; + case Preserve::Feature::kRock: + break; + case Preserve::Feature::kBrush: + break; + case Preserve::Feature::kGrass: + move(); + eat(); + findHerd(); + break; + case Preserve::Feature::kWater: + move(); + drink(); + findHerd(); + break; + } + + switch (toHortonsRight) + { + case Preserve::Feature::kUnknown: + break; + case Preserve::Feature::kHerd: + herdfound = true; + break; + case Preserve::Feature::kDirt: + move(); + findHerd(); + break; + case Preserve::Feature::kRock: + break; + case Preserve::Feature::kBrush: + break; + case Preserve::Feature::kGrass: + move(); + eat(); + findHerd(); + break; + case Preserve::Feature::kWater: + move(); + drink(); + findHerd(); + break; + } + } +} \ No newline at end of file