🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Burak HABER / C# / Kalıtım

1-) C# - Kalıtım




Form1.cs[Design]


Form1.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

 

namespace SınıfOlusturmaVeNesneKavrami

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

            araba rb = new araba();

            rb.renk = "mavi";

            rb.hizi = 160;

            rb.motor = 1245.56;

            rb.fiyat = 50000;

            rb.durum = 's';

            rb.YIL = -2016;

            rb.MARKASI = "Golf";

            rb.muayene = 2017;

            rb.plaka = "34 Aİ 1453";

            rb.sahip = "Fatih Mehmet";

 

            label1.Text = rb.renk;

            label2.Text = rb.hizi.ToString();   

            label3.Text = rb.motor.ToString();   

            label4.Text = rb.fiyat.ToString();

            label5.Text = rb.durum.ToString();

            label6.Text = rb.YIL.ToString();

            label7.Text = rb.MARKASI;

 

            label8.Text = rb.muayene.ToString();

            label9.Text = rb.plaka;

            label10.Text = rb.sahip;

 

            pictureBox1.BackColor = Color.CadetBlue;

        }

    }

}


araba.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace SınıfOlusturmaVeNesneKavrami

{

    class araba : ArabaDetay  //Katılım işlemi;araba.cs ye ArabaDetay.cs Eklendi.

    {

        public string renk;

        public int hizi;

        public double motor;

        public char durum;

        public int fiyat;

        private int yil;

        private string marka;

 

        public int YIL

        {

            get { return yil; }

            set { yil = Math.Abs(value); }// eksi değer girse bile + ya çevirir.

        }

        public string MARKASI

        {

            get { return marka; }

            set { marka = value.ToUpper(); }// hepsini büyük harfe çevirir.

        }

 

    }

}


ArabaDetay.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace SınıfOlusturmaVeNesneKavrami

{

    class ArabaDetay

    {

        public string plaka;

        public int muayene;

        public string sahip;

    }

}

 

 2021 Mart 11 Perşembe
 441