private void initializeFieldsMatrix() { m_fieldMatrix = new Field[m_width, m_height]; for (int col = 0; col < m_width; col++) { for (int row = 0; row < height; row++) { //dostęp do itego elementy macierzy m_fieldMatrix[col, row] = new FloorField(); } } }
public void polymorphPlace() { Crate crate = new Crate(currentField); Truck truck = new Truck(currentField); Wall wall = new Wall(); FloorField floorField = new FloorField(); WallField wallField = new WallField(); EmptyField emptyField = new EmptyField(); floorField.Place(crate); wallField.Place(crate); emptyField.Place(crate); }
override public void Visit(FloorField floorField) { if (floorField.IsEmpty()) { _fieldRepresentation = '.'; } else if (floorField.Content is Truck) { _fieldRepresentation = '@'; } else if (floorField.Content is Crate) { _fieldRepresentation = '#'; } }
public void polymorphToChar() { Crate crate = new Crate(currentField); Truck truck = new Truck(currentField); Wall wall = new Wall(); FloorField floorField = new FloorField(); TargetField targetField = new TargetField(); WallField wallField = new WallField(); EmptyField emptyField = new EmptyField(); crate.ToChar(); truck.ToChar(); wall.ToChar(); floorField.ToChar(); wallField.ToChar(); emptyField.ToChar(); targetField.ToChar(); }