Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            TempObject = new EngineClass();


            TempObject.SetNoofcylanders(Convert.ToInt16(textBox1.Text));
            TempObject.SetVolumeCC(Convert.ToInt16(textBox2.Text));
            //TempObject.SetEnginetype(Convert.ToBoolean(radioButton1.Text));
            TempObject.SetTorque(Convert.ToInt16(textBox3.Text));
            TempObject.SetHorsepower(Convert.ToInt16(textBox4.Text));
            MessageBox.Show("Values are set in object");
        }
Esempio n. 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //int x; The compiler allocates memory for the variable in stack
            EngineClass EnginObject;  // it is only a declaration

            CarObject   = new CarClass();
            EnginObject = new EngineClass(); // the compiler allocates memory for variable in heap
                                             // and it is completely reclaimable
                                             // as a side effect of creating this object, constructor will run
            EnginObject.SetNoofcylanders(2);
            EnginObject.SetVolumeCC(5);
            //EnginObject.SetEnginetype(false);
            EnginObject.SetTorque(5);
            EnginObject.SetHorsepower(2200);
            MessageBox.Show(EnginObject.MakeString());
        }