Beispiel #1
0
        static void Main(string[] args)
        {
            Transportasi transportasi;          // Menggunakan Abstract Class

            transportasi = new Pesawat();
            transportasi.Kendaraan();

            Console.WriteLine();
            transportasi = new Mobil();
            transportasi.Kendaraan();

            Console.WriteLine();
            transportasi = new Motor();
            transportasi.Kendaraan();


            /*ITransportasi transportasi;       // Menggunakan Interface Class
             * transportasi = new Pesawat();
             * transportasi.Kendaraan();
             * Console.WriteLine();
             * transportasi = new Mobil();
             * transportasi.Kendaraan();
             * Console.WriteLine();
             * transportasi = new Motor();
             * transportasi.Kendaraan();*/

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            inheritance
            Console.WriteLine("Inheritance");

            Mobil   mobil   = new Mobil();
            Motor   motor   = new Motor();
            Perahu  perahu  = new Perahu();
            Pesawat pesawat = new Pesawat();

            perahu.Melaju();
            perahu.Warna      = "Hijau";
            perahu.Kecepatan  = 30;
            perahu.JumlahRoda = 0;
            Console.WriteLine("Warna Perahu :{0} ", perahu.Warna);
            Console.WriteLine("Kecepatan Perahu :{0} ", perahu.Kecepatan);
            Console.WriteLine("Jumlah roda Perahu :{0} ", perahu.JumlahRoda);
            Console.WriteLine("---------------------");

            mobil.Melaju();
            Console.WriteLine("Warna Mobil :{0} ", mobil.Warna);
            Console.WriteLine("Kecepatan Mobil :{0} ", mobil.Kecepatan);
            Console.WriteLine("Jumlah roda Mobil :{0} ", mobil.JumlahRoda);
            Console.WriteLine("---------------------");

            motor.Melaju();
            Console.WriteLine("Warna Motor :{0} ", motor.Warna);
            Console.WriteLine("Kecepatan Motor :{0} ", motor.Kecepatan);
            Console.WriteLine("Jumlah roda Motor :{0} ", motor.JumlahRoda);
            Console.WriteLine("---------------------");

            pesawat.Melaju();
            Console.WriteLine("Warna Pesawat :{0} ", pesawat.Warna);
            Console.WriteLine("Kecepatan Pesawat :{0} ", pesawat.Kecepatan);
            Console.WriteLine("Jumlah roda Pesawat :{0} ", pesawat.JumlahRoda);

            polimorfisme
            Console.WriteLine("\nPolimorfisme");

            Kendaraan[] kendaraan = new Kendaraan[4];
            kendaraan[0] = new Mobil();
            kendaraan[1] = new Motor();
            kendaraan[2] = new Perahu();
            kendaraan[3] = new Pesawat();

            for (int i = 0; i < kendaraan.Length; i++)
            {
                if (kendaraan[i] is Perahu)
                {
                    (kendaraan[i] as Perahu).Berlayar();
                }
                else
                {
                    kendaraan[i].Melaju();
                }
            }

            Console.ReadKey();
        }
Beispiel #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            plane       = new Pesawat(spriteBatch, Content.Load <Texture2D>("png/player"), new Vector2(225f, 450f), 120, 120, Content.Load <Texture2D>("png/laserGreenShot"));

            // TODO: use this.Content to load your game content here
            keyboardState = Keyboard.GetState();
        }
        public ActionResult Delete(PesawatModel model)
        {
            Pesawat pesawat = context.Pesawats.Where(e => e.Id == model.Id).
                              SingleOrDefault();

            context.Pesawats.DeleteOnSubmit(pesawat);
            context.SubmitChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Create(PesawatModel model)
        {
            Pesawat pesawat = new Pesawat()
            {
                MaskapaiId = model.MaskapaiId,
                Jadwal     = model.Jadwal,
                TipeId     = model.TipeId,
                PilotId    = model.PilotId
            };

            context.Pesawats.InsertOnSubmit(pesawat);
            context.SubmitChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(PesawatModel model)
        {
            Pesawat pesawat = context.Pesawats.Where(e => e.Id == model.Id).
                              SingleOrDefault();

            pesawat.MaskapaiId = model.MaskapaiId;
            pesawat.Jadwal     = model.Jadwal;
            pesawat.TipeId     = model.TipeId;
            pesawat.PilotId    = model.PilotId;

            context.SubmitChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            //Kendaraan kendaraan;

            //kendaraan = new Pesawat();
            //kendaraan.Bergerak();

            //Console.WriteLine();
            //kendaraan = new Mobil();
            //kendaraan.Bergerak();

            //Console.WriteLine();
            //kendaraan = new Motor();
            //kendaraan.Bergerak();

            //Console.WriteLine();
            //kendaraan = new Truck();
            //kendaraan.Bergerak();

            //Console.WriteLine();
            //kendaraan = new Bus();
            //kendaraan.Bergerak();

            IKendaraan kendaraan;

            kendaraan = new Pesawat();
            kendaraan.Bergerak();

            Console.WriteLine();
            kendaraan = new Mobil();
            kendaraan.Bergerak();

            Console.WriteLine();
            kendaraan = new Motor();
            kendaraan.Bergerak();

            Console.WriteLine();
            kendaraan = new Truck();
            kendaraan.Bergerak();


            Console.WriteLine();
            kendaraan = new Bus();
            kendaraan.Bergerak();

            Console.ReadKey();
        }
Beispiel #8
0
 void Start()
 {
     pesawat           = this.GetComponent <Pesawat>();
     pesawat.limitMove = false;
 }
Beispiel #9
0
 void Start()
 {
     pesawat = FindObjectOfType <Pesawat>();
 }