Skip to content

My own changes codecademy learn swift #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions 3-conditionals/magic-8-ball/Magic8Balldeiabb.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//Projeto da bola magica

var playerName = ""

var playerQuestion =

"Eu vou ter um marido?"

var randomNumber = Int.random(in: 0...9)

//print(randomNumber)

var eightBall: String

// Eles pediram para fazer esse if statement e depois substituir por ternary conditional

//if playerName == "" {print(playerQuestion)}

//else {print("\(playerName) asks: \(playerQuestion)")}



playerName == "" ? print(playerQuestion) : print("\(playerName) asks: \(playerQuestion)")



switch randomNumber {

case let x where x == 1: eightBall = "Yes - definitely"

case let x where x == 2: eightBall = "It is decidedly so"

case let x where x == 3: eightBall = "Without a doubt"

case let x where x == 4: eightBall = "Replay hazy, try again"

case let x where x == 5: eightBall = "Ask again later"

case let x where x == 6: eightBall = "Better not tell you now"

case let x where x == 7: eightBall = "My sources say no"

case let x where x == 8: eightBall = "Outlook not so good"

case let x where x == 9: eightBall = "Very doubtful"

default: eightBall = "Error"

}



print("Magic 8 Ball's answer: \(eightBall)")