Protocols kullanımı ve kodlaması

in #utopian-io7 years ago (edited)

Selamlar , Bu dersimizin konusu protokollerdir . Protocol anlatımı ve kodlama şekillerinden bahsettim . Proje yapmamıza çok az kaldı . Lütfen terimleri tam olarak kavrıyalım ve öğrenelim arkadaşlar . İleride zorluk çekmiyelim . İyi seyirler , İyi dersler .

Greetings, this is the protocol of our course. I talked about protocol narration and coding. I have not done a project very well. Please fully understand the terms and let's learn friends. I will have difficulty in the future. Good looking, Good lectures.


Projemizin Kodları
(Project Code)





import UIKit

//**Protocols: Method(fonksiyon), propery(özellikler) taslak olarak tanımlamamıza olanak sağlayan yapılara denir. Struct,Class,Enum gibi yapılara uygulanabilir. OOP kavramının eksikliklerine çözüm getirmek için ortaya atılmıştır. POP ( Protocol oriented programming) olarak da anılır.**

**//Sözleşme gibidir uyulması zorunludur.**

//class Arac{

//    var name:String = ""

//}

//

//class Araba{

//    var tekerlekSayisi:Int = 4

//}

//

//class BMW:Arac,Araba{

//    var model:Int = 0

//}

//

**////Class ve Struct yapılarında multiple ingheritance olayı yoktur..**

**//Protocolerde birden fazla miras alma olayı vardır**

protocol Oyuncu{

    var isim:String {get}

    var canliMi:Bool {get set}

    var canSayisi:Int {get set}

    

    

}

extension Oyuncu{

    mutating func vurulma() {

        

        if canSayisi > 0 {

            canSayisi -= 1

            

            if canSayisi == 0 {

                canliMi = false // Öldü oyuncu

            }

        } else{

            canliMi = false // Zaten ölmüş

        }

        

        let durum = canliMi ? String(repeating:"❤️", count:canSayisi) : "💀"

        

        print("\(isim) : \(durum)")

    }

}

class SavasOyunu:Oyuncu{

    var isim: String

    

    var canliMi: Bool = true //Başlangıç değeri

    

    var canSayisi: Int = 3 //Başlangıç için 3 can hakkı veriyoruz

    

    init(isim:String) {

        self.isim = isim

    }

    

}

var gta = SavasOyunu(isim: "Swift")

gta.canSayisi

gta.vurulma()

gta.vurulma()

gta.vurulma()





  • Video ya ingilizce çeviri yapana " 1 SBD " Ödül verilecektir

  • The person who makes video or english translation will be awarded "1 SBD".


Videoma ingilizce çeviri yapabilirsiniz
English subtitles can be added to the video.

Kodlara github adresimden'de ulaşabilirsiniz
You can access the code file from my "Githup" account


Önceki derslerimiz / Previous lessons.**




Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @kerimcaglar I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.029
BTC 58225.92
ETH 3120.30
USDT 1.00
SBD 2.50