-
Notifications
You must be signed in to change notification settings - Fork 12
Ich kriege hier immer einen Bad Exe Error beim Erstellen einer Hand. #10
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
base: master
Are you sure you want to change the base?
Conversation
… du mir sagen, woran das liegt?
04 - Poker.playground/Contents.swift
Outdated
| import UIKit | ||
|
|
||
| enum Ranks: Int, CustomStringConvertible { | ||
| case Ass = 1, König, Dame, Bube, Zehn, Neun, Acht, Sieben, Sechs, Fünf, Vier, Drei, Zwei |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entferne einfach das = 1 hier und...
|
Relativ weit unten bei |
04 - Poker.playground/Contents.swift
Outdated
| while cards.count < 5 { | ||
| print("\(cards.count)") | ||
| let newCard = Card.createCard() | ||
| if newCard != cards[cards.count] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cards[cards.count] ist immer eine Laufzeitfehler, denn die Indizes eines Arrays sind 0..<count, d.h. maximal count-1.
Das append vor dem while brauchst du gar nicht, denke ich. Aber im while solltest du nicht nur die letzte Karte prüfen (das wäre cards[cards.count - 1]) sondern alle bereits erstellten, also z.B. mit cards.contains(newCard).
| print("\(cards.count)") | ||
| let newCard = Card.createCard() | ||
| if cards.contains(newCard) { | ||
| break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
break verlässt die while-Schleife, du brauchst hier continue.
|
2/3 Pt. erstmal, kannst du aber auch noch fertig schreiben. |
Kannst du mir sagen, woran das liegt?
Ich versuche das jetzt fast seit zwei Wochen und falle bald vom Glauben ab.
Bis zur Funktion die Karten zu vergleichen bin ich erst gar nicht gekommen.