Saturday, June 22, 2024

🎉 I just finished Day 13 of the #100DaysOfSwiftUI at https://www.hackingwithswift.com/100/swiftui/13

 protocol Building {

    var rooms: Int { get }

    var cost: Int { get }

    var agent: String { get }

    func salesSummary()

}


extension Building {

    func salesSummary() {

        print("""

                SUMMARY

                Building Type: \(Self.self)

                Rooms: \(rooms)

                Cost: \(cost)

                Agent: \(agent)

                \n

                """)

    }

}

              

struct House: Building {

    var rooms: Int

    var cost: Int

    var agent: String

}


struct Office: Building {

    var rooms: Int

    var cost: Int

    var agent: String

}


let house = House(rooms: 6, cost: 150_000, agent: "Jenna")

house.salesSummary()


let office = Office(rooms: 2, cost: 50_000, agent: "Gianna")

office.salesSummary()


let extHouse = House(rooms: 5, cost: 250_000, agent: "Robert")

extHouse.salesSummary()

No comments:

Post a Comment

🎉 I just finished Day 19 of the #100DaysOfSwiftUI at https://www.hackingwithswift.com/100/swiftui/19

 Made a Temperature Converter App for the SwiftUI Challenge Day!