public static void Main(string[] args) { // First one Potato potato = new Potato(); if (potato != null) { bool isRotten = potato.IsRotten; bool isPeeled = potato.IsPeeled; if (isPeeled && isRotten) { Cook(potato); } } // Second one const int MinX = 10; const int MaxX = 30; const int MinY = 0; const int MaxY = 10; int x = 0; int y = 0; if (IsInRange(x, y, MinX, MaxX, MinY, MaxY) & ShouldVisitCell) { VisitCell(); } }
private static void Cook(Potato potato) { if (PotatoIsProvided(potato) && potato.IsPeeled && !potato.IsRotten) { Console.WriteLine("Cooking"); } }
private static bool PotatoIsProvided(Potato potato) { if (potato != null) { return true; } else { throw new ArgumentOutOfRangeException("A Potato object should be passed"); } }
public static void Main() { // Potato problem Potato potato = new Potato(); if (potato != null && (potato.HasBeenPeeled && potato.IsNotRotten)) { Potato.Cook(potato); } // Matrix visited cell problem CheckViableCell(); }
public static void Main(string[] args) { Potato potato = new Potato(); //// First statement if (potato != null) { if (potato.HasBeenPeeled && potato.NotRotten) { Cook(potato); } } //// Second statement var x = 3; var y = 5; bool shouldVisitCell = true; if (InRange(x, y) && shouldVisitCell) { VisitCell(); } }
public static void Main() { const int MIN_ROW = 0; const int MAX_ROW = 25; const int MIN_COL = 0; const int MAX_COL = 5; /* Potato potato; if (potato != null) if (!potato.HasNotBeenPeeled && !potato.IsRotten) Cook(potato); */ Potato potato = new Potato(); potato.IsPeeled = true; Cook(potato); /* if (x >= MIN_X && (x =< MAX_X && ((MAX_Y >= y && MIN_Y <= y) && !shouldNotVisitCell))) { VisitCell(); } */ int row = 20; int col = 50; bool canBeVisited = true; if (isValidPosition(row, MIN_ROW, MAX_ROW) && isValidPosition(col, MIN_COL, MAX_COL) && canBeVisited) { VisitCell(); } }
private static void Cook(Potato potato) { throw new NotImplementedException(); }