Skip to content

Commit

Permalink
Day 12 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrlpld committed Apr 19, 2023
1 parent eb7f2b8 commit f1e47c2
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
Binary file not shown.
54 changes: 54 additions & 0 deletions day-10.playground/Contents.swift
@@ -0,0 +1,54 @@
import Cocoa

struct Album {
let title: String
let artist: String
let year: Int

func printSummary() {
print("\(title) (\(year)) by \(artist)")
}
}

let red = Album(title: "Red", artist: "Taylor Swift", year: 2012)
let wings = Album(title: "Wings", artist: "BTS", year: 2016)

print(red.title)
print(wings.artist)

red.printSummary()
wings.printSummary()


struct Game {
var score = 0 {
didSet {
print("Score is now \(score)")
}
}
}

var game = Game()
game.score += 10
game.score -= 3
game.score += 1


struct App {
var contacts = [String]() {
willSet {
print("Current value is: \(contacts)")
print("New value will be: \(newValue)")
}

didSet {
print("There are now \(contacts.count) contacts.")
print("Old value was \(oldValue)")
}
}
}

var app = App()
app.contacts.append("Adrian E")
app.contacts.append("Allen W")
app.contacts.append("Ish S")
4 changes: 4 additions & 0 deletions day-10.playground/contents.xcplayground
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='macos' buildActiveScheme='true' importAppTypes='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

0 comments on commit f1e47c2

Please sign in to comment.