static void Main(string[] args) { var facade = new Facade.Facade(); facade.DoWork_A(); facade.DoWork_B(); }
public object GetObject(int type) { Facade.Facade facade = new Facade.Facade(Owner, Battle, x, endx, y, endy, isHorizontal); System.Diagnostics.Debug.WriteLine("Facade: Object was created"); System.Diagnostics.Debug.WriteLine("ShipAdapter: Returning created ship"); return(facade.GetShip()); }
public void FacadeTest() { // The client code may have some of the subsystem's objects already // created. In this case, it might be worthwhile to initialize the // Facade with these objects instead of letting the Facade create // new instances. var subsystem1 = new SubSystem1(); var subsystem2 = new SubSystem2(); var facade = new Facade.Facade(subsystem1, subsystem2); Client.ClientCode(facade).Should().Be(StructuralText.FacadeResult); }
public override void EndGame(Facade.Facade facade, Enemy enemy, Form1 board, Player player) { if (player.id == enemy.whoWon) { board.LabelText = "You won"; facade.stopTimers(); facade.setState(new GameOver()); facade.gameAction(); } else { Successor.EndGame(facade, enemy, board, player); } }
protected sealed override void BattleShipObjects(int battleId, string playerBoard) //protected override void BattleShipObjects(int battleId, string playerBoard) { var db = ApplicationDbContext.GetInstance(); Battle battle = db.Battles.Find(battleId); var currentUserName = getCurrentUserName(); var currentPlayer = db.Users.FirstOrDefault(x => x.UserName == currentUserName); var copy = playerBoard; var planes = "os"; for (int i = 0; i < copy.Length; i++) { if (planes.Contains(copy[i]) && planes.Length > 0) { var x = i % 10; var y = i / 10; int endx = 0; int endy = 0; bool isHorizontal = i < copy.Length - 1 && copy[i + 1] == copy[i] ? true : false; int type = 0; switch (copy[i]) { case 'o': /**vienvietis**/ type = 1; isHorizontal = true; endx = x; endy = y; break; case 's': type = 2; endx = isHorizontal ? x + 1 : x; endy = isHorizontal ? y : y + 1; break; } planes = planes.Remove(planes.IndexOf(copy[i]), 1); var facade = new Facade.Facade(currentPlayer, battle, x, endx, y, endy, isHorizontal); IAdapter planeAdapter = new PlaneAdapter(currentPlayer, battle, x, endx, y, endy, isHorizontal); Plane plane = (Plane)planeAdapter.GetObject(0); db.Planes.Add(plane as Plane); } } System.Diagnostics.Debug.WriteLine("TemplatePlanes : Template. Required operation- BattleShipObjects"); }
// The client code works with complex subsystems through a simple // interface provided by the Facade. When a facade manages the lifecycle // of the subsystem, the client might not even know about the existence // of the subsystem. This approach lets you keep the complexity under // control. public static void ClientCodeFacade(Facade.Facade facade) { Console.Write(facade.Operation()); }
public abstract void EndGame(Facade.Facade facade, Enemy enemy, Form1 board, Player player);
private void btnGuardarUsu_Click(object sender, EventArgs e) { try { if (txtNombUsu.Text == "") { MessageBox.Show("Completar el nombre de usuario"); txtNombUsu.Focus(); return; } if (txtApellido.Text == "") { MessageBox.Show("Completar el Apellido"); txtApellido.Focus(); return; } if (txtNombre.Text == "") { MessageBox.Show("Completar el Nombre"); txtNombre.Focus(); return; } if (txtCalle.Text == "") { MessageBox.Show("Completar la Calle"); txtCalle.Focus(); return; } if (txtNroCalle.Text == "") { MessageBox.Show("Completar le numero de calle"); txtNroCalle.Focus(); return; } if (txtEmail.Text == "") { MessageBox.Show("Completar el Mail"); txtEmail.Focus(); return; } if (cboxGrupo.Text == "") { MessageBox.Show("Debe seleccionar un grupo"); cboxGrupo.Focus(); return; } usuarios_c oUsuC = new usuarios_c(); usuario oUsua = oUsuC.Get("0", 0, txtNombUsu.Text, ""); if (oUsua.Nomb_usuario != null) { MessageBox.Show("El nombre de usuario ya existe"); return; } //usuarios_c oUsuC = new usuarios_c(); Facade.Facade oFacade = new Facade.Facade(); usuario oUsuario = new usuario(); oUsuario.Apellido = txtApellido.Text; oUsuario.Nombre = txtNombre.Text; oUsuario.Nomb_usuario = txtNombUsu.Text; oUsuario.Direccion_c = txtCalle.Text; oUsuario.Direccion_n = txtNroCalle.Text; oUsuario.Email = txtEmail.Text; oUsuario.Telefono = Convert.ToInt32(txtTelefono.Text); oUsuario.Pass = ""; Program.ComboboxItem itemSelect = (Program.ComboboxItem)cboxGrupo.SelectedItem; int result = oFacade.AltaUsuario(oUsuario, Convert.ToInt32(itemSelect.Value)); if (result == 1) { MessageBox.Show("El Usuario se ha cargado con éxito y se le ha mandado el mail al usuario con su contraseña"); this.Close(); } else { MessageBox.Show("Error: No se pudo cargar el usuario."); } } catch (Exception) { } }
public override void EndGame(Facade.Facade facade, Enemy enemy, Form1 board, Player player) { board.LabelText = "Game over player" + enemy.whoWon + " won"; facade.stopTimers(); }