Post

Replies

Boosts

Views

Activity

Reply to How to write a method to sort out black and red cards Newbie to Swift
// red hearts and diamonds. // black spades and clubs // 20 Jan 2023 ML // a function called checkRed to determine red hearts and diamonds func checkRed(RHearts:Bool, RDiamonds:Bool)-> Bool { let redVal: Bool // redVal is a return value in boolean format redVal = true // if the parameters RHearts,RDiamonds are set to true means red cards // let RHearts = // let RDiamonds = // they are red hearts & red diamond cards selected // redVal is boolean //logic must be ANDED if (RHearts && RDiamonds) { print ("Red cards are :",Suit.Diamonds,Suit.Hearts ) } else { _ = false print("Black cards are :", Suit.Clubs, Suit.Spades ) } return redVal }// end of checkRed func brace checkRed(RHearts: true, RDiamonds:true)
Jan ’23
Reply to How to write a method to sort out black and red cards Newbie to Swift
var Array = [ "Ace:1","Two:2","Three:3 ","Four:4","Five:5 ","Six:6","Seven:7","Eight:8","Nine:9","Ten:10", "Jack:11","Queen:12","King:13"] let cardType = ["Spades","Hearts","Diamonds","Clubs"] for cardType in cardType { for Array in Array { print("(Array) of (cardType) ") } print("-----------------") }
Replies
Boosts
Views
Activity
Jan ’23
Reply to How to write a method to sort out black and red cards Newbie to Swift
// red hearts and diamonds. // black spades and clubs // 20 Jan 2023 ML // a function called checkRed to determine red hearts and diamonds func checkRed(RHearts:Bool, RDiamonds:Bool)-> Bool { let redVal: Bool // redVal is a return value in boolean format redVal = true // if the parameters RHearts,RDiamonds are set to true means red cards // let RHearts = // let RDiamonds = // they are red hearts & red diamond cards selected // redVal is boolean //logic must be ANDED if (RHearts && RDiamonds) { print ("Red cards are :",Suit.Diamonds,Suit.Hearts ) } else { _ = false print("Black cards are :", Suit.Clubs, Suit.Spades ) } return redVal }// end of checkRed func brace checkRed(RHearts: true, RDiamonds:true)
Replies
Boosts
Views
Activity
Jan ’23
Reply to How to write a method to sort out black and red cards Newbie to Swift
Thanks Claude31 for your help . I am going and type on computer all the book code from a book by Apple 525 pages long. I am on page 21. Its free online book At this chapter just learning enum and structures. But this book ask for method to sort out black and red cards.
Replies
Boosts
Views
Activity
Jan ’23