static void Main(string[] args) { ICar car = new M3(); car.CarStopped += new EventHandler(OnCarStopped); car.Start(); car.PressAccelerator(10); car.PressBrake(10); }
private static void CarInterface() { ICar[] cars = { new M3 { Color = Color.Silver }, new Hooptie { Color = Color.Black } }; foreach (var car in cars) { PrintInfo(car); car.Start(); car.PressAccelerate(2); car.PressAccelerate(10); car.PressBrake(2); car.PressBrake(10); } Console.WriteLine("Here is a new BMW M3"); ICar m3 = new M3(); m3.Start(); Console.WriteLine("Here is a new hooptie!"); Hooptie hooptie = new Hooptie(); hooptie.Start(); }
private void M4_Leave(object sender, EventArgs e) { try { conexion.Open(); nombre = (M2.Text); localidad = (M3.Text); iata = Convert.ToInt32(M4.Text); DataGridViewRow FILA = dataGridView1.CurrentRow; id = Convert.ToInt32(FILA.Cells[0].Value); actualizarM(); dataSet.Clear(); dataGridView1.DataSource = dataSet.Tables[0]; Query = "SELECT * FROM aeropuertos;"; NpgsqlDataAdapter add = new NpgsqlDataAdapter(Query, conexion); add.Fill(dataSet); dataGridView1.DataSource = dataSet.Tables[0]; M1.Clear(); M2.Clear(); M3.Clear(); M4.Clear(); } catch (Exception) { MessageBox.Show("Los datos no fueron modificados"); } }
static void Main(string[] args) { ICar[] cars = { new M3 { Color = Color.Silver }, new Hooptie { Color = Color.Black }, }; foreach (ICar car in cars) { PrintInfoCar(car); car.CarStopped += OnCarStopped; car.Star(); car.PressAcelerator(2); car.PressAcelerator(10); car.PressBreak(); car.PressAcelerator(20); car.ChangeMarche(); } ; QuitTracker bob = new QuitTracker { Name = "Bob" }; QuitTracker sandy = new QuitTracker { Name = "Sandy" }; KeystrokeHandler keystrokehandler = new KeystrokeHandler(); keystrokehandler.OnKey += GotKey; keystrokehandler.OnQuitting += bob.QuitHandler; keystrokehandler.OnQuitting += sandy.QuitHandler; keystrokehandler.OnQuitting += OnQuit; keystrokehandler.Run(); object carM3 = new M3(); Type type = carM3.GetType(); Console.WriteLine(type.Assembly.GetName().Version); Console.WriteLine(carM3); object[] objects = { new M3(), new Hooptie(), }; foreach (object obj in objects) { Console.WriteLine(obj); Is(obj); As(obj); Cast(obj); Console.WriteLine("------------- "); } }
static void Main(string[] args) { object car = new M3(); Type type = car.GetType(); Console.WriteLine(type.Assembly.GetName().Version); Console.WriteLine(car); }
private void listBox1_MouseClick(object sender, MouseEventArgs e) { M3 selectedFahrzeug = (M3)listBox1.Items[listBox1.SelectedIndex]; labelListboxFarbe.Text = selectedFahrzeug.Farbe; labelListboxHerstellungswerk.Text = selectedFahrzeug.HerstellungsWerk; label6.Text = selectedFahrzeug.Listenpreis.ToString(); }
public static void Menu2() { M3 m3 = new M3(5); M5 m5 = new M5(7); M7 m7 = new M7(9); char done = 'n'; Console.WriteLine("Please choose a single or multple item"); do { Console.WriteLine("a. M3: 5$"); Console.WriteLine("b. M5: 7$"); Console.WriteLine("c. M7: 9$"); char order = char.Parse(Console.ReadLine()); switch (order) { case 'a': Count += m3.Price(); using (StreamWriter w = File.AppendText("bill.txt")) { w.WriteLine("M3: 5$"); } break; case 'b': Count += m5.Price(); using (StreamWriter w = File.AppendText("bill.txt")) { w.WriteLine("M5: 7$"); } break; case 'c': Count += m7.Price(); using (StreamWriter w = File.AppendText("bill.txt")) { w.WriteLine("M7: 9$"); } break; default: Console.WriteLine("Not on the menu!"); break; } Console.Write("Order Complete?(y/n)"); done = Char.Parse(Console.ReadLine()); Console.Clear(); cashRegister += Count; }while (done == 'n' || done == 'N'); Console.WriteLine("Please take your bill"); using (StreamWriter w = File.AppendText("bill.txt")) { w.WriteLine("Total Bill: {0}", Count); } }
private static void Cast(object obj) { try { M3 m3 = (M3)obj; Console.WriteLine("(M3) return {0}", m3); } catch (InvalidCastException) { Console.WriteLine("InvalidCastException"); } }
private static void CarStoppedDelegate() { ICar car = new M3(); car.CarStopped += OnCarStopped; car.Start(); car.PressAccelerate(10); car.PressBrake(10); }
private void Button1_Click(object sender, EventArgs e) { M3 m3 = new M3(); m3.Farbe = textBox1.Text; m3.HerstellungsWerk = textBox2.Text; m3.Listenpreis = float.Parse(textBox3.Text); Autos.Add(m3); listBox1.Items.Add(m3); }
public static void PreventPolymorphism() { // First, I created a subclass of BMW. // Then we instantiate the sub-sub class (Car --> BMW --> M3). M3 myM3 = new M3(260, "red", "M3 Super Turbo"); // Now look within the M3 class to see how the following method has been sealed at the BMW level. // The polymorphic behavior has been prevented. myM3.BaseMethodWithOverride(); // You can also seal entire classes. Check out Audi and TT classes to see the idea in action. }
private static void Cast(object car) { try { M3 m3 = (M3)car; Console.WriteLine("M3 returned a {0}", m3); } catch (Exception ex) { Console.WriteLine("Exception : {0}", ex.Message); } }
public void AddShelvesTest() { var m1 = new M1(2, 50); var groupIds =new int[]{49, 50, 51, 52}; var m2 = new M2(groupIds); var m3 = new M3(49, "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg"); var imgs = new string[] { "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg" }; var m4 = new M4(groupIds, imgs); var m5 = new M5(groupIds, "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg"); var result = ShelfApi.AddShelves("accessToken", m1, m2, m3, m4, m5, "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "测试货架"); Console.Write(result); Assert.IsNotNull(result); }
public void AddShelvesTest() { var m1 = new M1(2, 50); var groupIds = new int[] { 49, 50, 51, 52 }; var m2 = new M2(groupIds); var m3 = new M3(49, "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg"); var imgs = new string[] { "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg" }; var m4 = new M4(groupIds, imgs); var m5 = new M5(groupIds, "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg"); var result = ShelfApi.AddShelves("accessToken", m1, m2, m3, m4, m5, "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "测试货架"); Console.Write(result); Assert.IsNotNull(result); }
public static void HasARelationshipExample() { // The inheritance examples we've seen so far are all 'is a' relationships. An M3 is a BMW. A BWM is a Car, etc. // In fact, all inheritance sets up 'is a' relationships. // But suppose we want to give more attributes to the base class car, such that all instances of cars (BMWs, Audis, and specific models of those) 'have a' property like a VIN? // This approach, the alternative to inheritance, is called 'composition.' // Then we can create a class like 'CarIDInfo' and establish a 'has a' relationship in the Car class. // Go to the Car class and see how the CarIdInfo class has been instantiated to say that Cars 'have a' carIdInfo. // We are basically instantiating the CarIDInfo class within each Car instantiation. This way, an object HAS another object, instead of BEING an instance of another class. // And given the methods defined in the Car class, we can get and set the car id info here. M3 myM3 = new M3(260, "red", "M3 Super Turbo"); myM3.SetCarIdInfo(11768, "Mario Andretti"); myM3.GetCarIdInfo(); }
public void Contravariant_Test() { // 逆变: 逆变(Foo<子类> = Foo<父类>) M3 <object> a = null; M3 <string> b = null; M4 <object> c = null; M4 <string> d = null; // b = a; //不支持逆变与协变 d = c; // 支持逆变 IC <object> ia = null; IC <string> ib = null; ID <object> ic = null; ID <string> id = null; //ib = ia; id = ic; IEnumerable <object> ie = null; IEnumerable <string> ig = null; //ig = ie; // 不支持逆变 ie = ig; // 支持协变 IEnumerable <object> data = new List <Product> { new Product { SysNo = 1, Price = 20m } }; IEnumerable <Product> source = null; //data = source; source = (IEnumerable <Product>)data; ie = source; }
// Start is called before the first frame update void Start() { StartCoroutine(Utils.SetVRDevice("OpenVR", true)); MC1 = M1.GetComponent <MasterController>(); MC2 = M2.GetComponent <MasterController>(); MC3 = M3.GetComponent <MasterController>(); MC4 = M4.GetComponent <MasterController>(); MC5 = M5.GetComponent <MasterController>(); MC6 = M6.GetComponent <MasterController>(); MC7 = M7.GetComponent <MasterController>(); MC8 = M8.GetComponent <MasterController>(); loadLevel(); currentPoseIndex = 0; }
public Aeropuertos() { InitializeComponent(); string servidor = "localhost"; int puerto = 5432; string usuario = "postgres"; int clave = 123; string baseDatos = "proyectgb"; cadenaConexion = "Server=" + servidor + "; " + "Port=" + puerto + "; " + "User Id=" + usuario + "; " + "Password="******"; " + "Database=" + baseDatos; conexion = new NpgsqlConnection(cadenaConexion); Console.WriteLine(cadenaConexion); try { conexion.Open(); } catch (Exception E) { } Query = "SELECT * FROM aeropuertos; "; NpgsqlDataAdapter add = new NpgsqlDataAdapter(Query, conexion); add.Fill(dataSet); dataGridView1.DataSource = dataSet.Tables[0]; dataGridView2.DataSource = dataSet.Tables[0]; dataGridView3.DataSource = dataSet.Tables[0]; A1.Clear(); A2.Clear(); A3.Clear(); A4.Clear(); M1.Clear(); M2.Clear(); M3.Clear(); M4.Clear(); conexion.Close(); Insertar(id, nombre, localidad, iata); }
private void B_Click(object sender, RoutedEventArgs e) { AchievementInfo.ClickTime++; var P = (sender as Button).Tag as Point; M3.Play(); pr.IsActive = true; if (Marked[P.x, P.y]) { return; } if (OpenedButton == 0) { SetMine((sender as Button).Tag as Point); watch.Start(); } else { } try { Unload(P); } catch (Exception) { } try { Refresh(); } catch (Exception) { } pr.IsActive = false; }
IEnumerator Merit() { yield return(new WaitForSeconds(Pause * 2)); M1.SetActive(true); yield return(new WaitForSeconds(Pause)); M2.SetActive(true); yield return(new WaitForSeconds(Pause)); M3.SetActive(true); yield return(new WaitForSeconds(Pause)); M4.SetActive(true); yield return(new WaitForSeconds(Pause)); M5.SetActive(true); yield return(new WaitForSeconds(Pause * 2)); Victory.SetActive(true); yield return(new WaitForSeconds(Pause * 2)); Application.LoadLevel("Credits"); }
public void Spawn <T, U, V, W>(M3 <T, U, V, W> m) { PrivateSpawn(m); }
public void Pool <T, U, V, W>(M3 <T, U, V, W> m) { PrivatePool(m); }
public void SyncContext <T, U, V, W>(M3 <T, U, V, W> m) { SyncContext(m); }
public void ShouldBeIgnored(M3 input) { }
// Reads the input files // Fills the TABLES with DATA from the files private void Fill_tables(MySqlConnection connection) { // Add data to RoomTable Console.WriteLine("We now add records to RoomTable\n"); using (StreamReader SR = new StreamReader("Room.txt")) { String S = SR.ReadLine(); // Loop through the file reading lines while (S != null) { String[] SArray = S.Split(','); // Room.txt contains tab-delimited fields. int M = Convert.ToInt32(SArray[1]); int Rm = Convert.ToInt32(SArray[0]); String SqlString = "Insert Into RoomTable (Room, Capacity, Smart) Values(" + "'" + Rm.ToString() + "', " + M.ToString() + ", '" + SArray[2] + "')"; //Console.WriteLine(SqlString); // Run the command MySqlCommand Command2 = new MySqlCommand(SqlString, connection); Command2.ExecuteNonQuery(); S = SR.ReadLine(); } // end of while } // end of using for StreamReader // Add data to OfficeTable Console.WriteLine("We now add records to OfficeTable\n"); using (StreamReader SR = new StreamReader("Office.txt")) { String S = SR.ReadLine(); // Loop through the file reading lines while (S != null) { String[] SArray = S.Split(','); // Room.txt contains tab-delimited fields. int M = Convert.ToInt32(SArray[1]); String SqlString = "Insert Into OfficeTable (Teacher , Office) Values(" + "'" + SArray[0] + "', " + M.ToString() + ")"; //Console.WriteLine(SqlString); // Run the command MySqlCommand Command2 = new MySqlCommand(SqlString, connection); Command2.ExecuteNonQuery(); S = SR.ReadLine(); } // end of while } // end of using for StreamReader // Add data to ClassTable Console.WriteLine("We now add records to ClassTable\n"); using (StreamReader SR = new StreamReader("Class.txt")) { // Ints to Convert strings to ints int M0; int M1; int M3; int M6; String S = SR.ReadLine(); while (S != null) { // Show the string in the console //Console.WriteLine(S); // THIS WAS FOR THE ORIGINAL INPUT FILE FOR CLASSES // If the line does not have Section 1 - ADD IT //if ( (S.IndexOf('-')) == -1 ) //{ // S = S.Insert((S.IndexOf(',')), "-1"); //} // This split was also for the original input, but still works // Split the String and Commas AND Dashes String[] SArray = S.Split(new Char[] { ',', '-' }, StringSplitOptions.RemoveEmptyEntries); // Room.txt contains tab-delimited fields. // Convert some stings to ints // Check if any of the INTS are passed in as NULL { if (SArray[0] != "null") { M0 = Convert.ToInt32(SArray[0]); } else { M0 = -1; } if (SArray[1] != "null") { M1 = Convert.ToInt32(SArray[1]); } else { M1 = -1; } if (SArray[3] != "null") { M3 = Convert.ToInt32(SArray[3]); } else { M3 = -1; } if (SArray[6] != "null") { M6 = Convert.ToInt32(SArray[6]); } else { M6 = -1; } } // If the file has NULL for primary keys - it will display a message box // Except for the "Section"... because the new input file has "section" as null // despite the fact that it MUST be part of the primary key // because there are classes with the same Number // Create the command String String SqlString = "Insert Into ClassTable (Class, Section, Teacher, Room, Time, Days, Enrollment) Values(" + (M0 == -1 ? "NULL" : M0.ToString()) + ", " + (M1 == -1 ? "1" : M1.ToString()) + ", " + (SArray[2] == "null" ? "NULL" : "'" + SArray[2] + "'") + ", " + (M3 == -1 ? "NULL" : M3.ToString()) + ", " + (SArray[4] == "null" ? "NULL" : "'" + SArray[4] + "'") + ", " + (SArray[5] == "null" ? "NULL" : "'" + SArray[5] + "'") + ", " + (M6 == -1 ? "NULL" : M6.ToString()) + ")"; // Output the command to console //Console.WriteLine(SqlString); // Make the command and RUN IT MySqlCommand Command2 = new MySqlCommand(SqlString, connection); Command2.ExecuteNonQuery(); // Get a new Line S = SR.ReadLine(); } // end of while } // end of using for StreamReader }
public void Do <T, U>(M3 <T, U> m) { DoAny(m); }
public SyncMethod NewSyncMethod <T, U, V, W>(M3 <T, U, V, W> @delegate) { return(new SyncMethod(this, @delegate)); }
public void Do <T, U, V, W, X, Y, Z>(M3 <T, U, V, W, X, Y, Z> m) { DoAny(m); }
public void Do <T, U, V, W, X>(M3 <T, U, V, W, X> m) { DoAny(m); }
public void Do <T, U, V>(M3 <T, U, V> m) { DoAny(m); }
public void Continue <T, U, V, W>(M3 <T, U, V, W> m) { PrivateContinue(m); }
public void Do <T, U, V, W>(M3 <T, U, V, W> m) { PrivateDo(m); }
public void M3(M3 input) { }