Learn Courses My Dashboard

Lesson 13 Challenge (14 day challenge)

I just started to work on the Lesson 13 challenge, and I got everything to display but I don’t know how to shuffle the objects and update the stats based on those changes. Any advice?

//
//  ContentView.swift
//  Shared
//
//  Created by Eric Beecroft on 10/3/21.
//

import SwiftUI

struct ContentView: View {
    @State var credits = 1000;
    @State var slot1;
    @State var slot2;
    @State var slot3;
    func slotMachine()
    {
        //Switch the apples around
    }
    var body: some View {
        VStack{
            VStack{
                Spacer()
                Text("SwiftUI Slots!")
                Spacer()
            }
            VStack{
                Spacer()
                Text("Credits: " + String(credits))
                Spacer()
            }
            HStack{
                Spacer()
                Image("apple")
                Spacer()
                Image("apple")
                Spacer()
                Image("apple")
                Spacer()
            }
            VStack{
                Spacer()
                Text("button")
                Spacer()
            }
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

have you tried doing lesson 14 and 15 yet?

There is only 13 lessons in Module 1 not 14 or 15.

oh sorry i totally mixed it up with the 2nd module which is 15/16 lessons…

you should check out the solution provided so you will be able to see Chris’ version of the solution

its just right there at the resources page of the free course

I am looking to understand the problem more than just know the solution. Its more like how do I get from what I have right now to what the solution in the resources is. That is what I am kind of struggling with.