public Location FinalLocation(string way, Location start) { Location stop = new Location(); stop = start; foreach (var item in way) { if (item == 'L' || item == 'R') { SpinningControl spin = new SpinningControl(); var data = spin.GetNextDirection(item, stop); stop = data; } else { MovingControl move = new MovingControl(); var data = move.MoveNextDirection(stop); stop = data; } } return(stop); }
public Location FinalLocation(string way, Location start) // Örnek = konumu ( 1 2 N ) - komutları ( LMLMLMLMM ) { Location stop = new Location(); stop = start; foreach (var item in way) // her hareketi ve o anki lokasyonunu metotlara gönderip son hareketini çekiyoruz. { if (item == 'L' || item == 'R') { SpinningControl spin = new SpinningControl(); var data = spin.GetNextDirection(item, stop); stop = data; } else { MovingControl move = new MovingControl(); var data = move.MoveNextDirection(stop); stop = data; } } return(stop); }