Exemple #1
0
        private void button6_Click(object sender, EventArgs e)
        {
            Tallguy tallguy = new Tallguy("Jonghyun Shin", 176);

            using (Stream output = File.Create(Directory.GetCurrentDirectory() + "\\Practice\\Serialized_tallguy.SJH"))
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(output, tallguy);
            }
        }
Exemple #2
0
        private void button7_Click(object sender, EventArgs e)
        {
            Form1 f1 = (Form1)Application.OpenForms["Form1"];

            using (Stream input = File.OpenRead(Directory.GetCurrentDirectory() + "\\Practice\\Serialized_tallguy.SJH"))
            {
                BinaryFormatter formatter = new BinaryFormatter();
                Tallguy         tallguy   = (Tallguy)formatter.Deserialize(input);
                f1.GB_Status_AppendText_Nextline(tallguy.Talkaboutyourself(), Color.Green);
            }
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Form1 f1 = (Form1)Application.OpenForms["Form1"];

            f1.GB_Status_AppendText_Nextline("---Normal (No Casting)---", Color.Purple);
            Tallguy tallguy = new Tallguy("Jonghyun Shin", 176);

            f1.GB_Status_AppendText_Nextline(tallguy.Talkaboutyourself(), Color.Red);
            f1.GB_Status_AppendText_Nextline(tallguy.FunnyThingIHave, Color.Red);
            f1.GB_Status_AppendText_Nextline(tallguy.Honk(), Color.Red);

            Scarayguy scaryguy = new Scarayguy();

            f1.GB_Status_AppendText_Nextline(scaryguy.FunnyThingIHave, Color.Blue);
            f1.GB_Status_AppendText_Nextline(scaryguy.ScraryThingIHave, Color.Blue);
            f1.GB_Status_AppendText_Nextline(scaryguy.Honk(), Color.Blue);

            Scary_Tallguy scary_tallguy = new Scary_Tallguy(tallguy.name, tallguy.height);

            f1.GB_Status_AppendText_Nextline(scary_tallguy.Talkaboutyourself(), Color.Green);
            f1.GB_Status_AppendText_Nextline(scary_tallguy.FunnyThingIHave, Color.Green);
            f1.GB_Status_AppendText_Nextline(scary_tallguy.ScraryThingIHave, Color.Green);
            f1.GB_Status_AppendText_Nextline(scary_tallguy.Honk(), Color.Green);
            f1.GB_Status_AppendText_Nextline("", Color.Purple);

            f1.GB_Status_AppendText_Nextline("---Up casting---", Color.Purple);
            ICrown[] Temp = new ICrown[3];
            Temp[0] = tallguy;       //Up casting
            Temp[1] = scaryguy;      //Up casting
            Temp[2] = scary_tallguy; //Up casting

            f1.GB_Status_AppendText_Nextline(Temp[0].FunnyThingIHave, Color.Red);
            f1.GB_Status_AppendText_Nextline(Temp[0].Honk(), Color.Red);
            f1.GB_Status_AppendText_Nextline(Temp[1].FunnyThingIHave, Color.Blue);
            f1.GB_Status_AppendText_Nextline(Temp[1].Honk(), Color.Blue);
            f1.GB_Status_AppendText_Nextline(Temp[2].FunnyThingIHave, Color.Green);
            f1.GB_Status_AppendText_Nextline(Temp[2].Honk(), Color.Green);
            f1.GB_Status_AppendText_Nextline("", Color.Purple);

            f1.GB_Status_AppendText_Nextline("---Down Casting---", Color.Purple);
            Scary_Tallguy Temp_Scary = Temp[2] as Scary_Tallguy; //Down Casting

            f1.GB_Status_AppendText_Nextline(Temp_Scary.Talkaboutyourself(), Color.Black);
            f1.GB_Status_AppendText_Nextline(Temp_Scary.FunnyThingIHave, Color.Black);
            f1.GB_Status_AppendText_Nextline(Temp_Scary.ScraryThingIHave, Color.Black);
            f1.GB_Status_AppendText_Nextline(Temp_Scary.Honk(), Color.Black);
            f1.GB_Status_AppendText_Nextline("", Color.Purple);
        }