Difference between revisions of "Mobile App Development 2021W Lecture 9"

From Soma-notes
Jump to navigation Jump to search
(Created page with "==Video== Video from the lecture given on February 8, 2021 [https://homeostasis.scs.carleton.ca/~soma/mad-2021w/lectures/comp1601-2021w-lec09-20210208.m4v is now available]....")
 
 
Line 2: Line 2:


Video from the lecture given on February 8, 2021 [https://homeostasis.scs.carleton.ca/~soma/mad-2021w/lectures/comp1601-2021w-lec09-20210208.m4v is now available].
Video from the lecture given on February 8, 2021 [https://homeostasis.scs.carleton.ca/~soma/mad-2021w/lectures/comp1601-2021w-lec09-20210208.m4v is now available].
==Notes==
<pre>
Lecture 9
------------
schedule
A1 solutions
T4 via live coding
Midterm
- midterm on March 3rd, 11:35 AM
- review on March 1st
- timed, 80 min, during class time
- download PDF of midterm from cuLearn
- upload solutions to cuLearn (via an assignment) before the end of exam period
- open book/internet, open note, NO COLLABORATION
- interviews afterwards to verify you understood what you said on the midterm
  - random + selected
  - you may volunteer
- if there is clear evidence that you don't know enough to have given the answers
  you did, then I'll be talking to the Dean
- questions on midterm are more conceptual than coding
  - do you know what is going on?
- treat the midterm as practice for the final
  - everything you do in this class is an opportunity to raise your grade
- midterm will all be short answer
  - some more conceptual, some based on specific code examples
  - any "code" in answers will be very short (at most 3 lines)
  - more on reading rather than writing code
Tutorial 4 is due Feb. 21st, before midnight
Assignment 2 is due Feb 26th
- midterm is based on Assignment 1 & 2, which are based on Tutorials 1-4
- (maybe Tutorial 5, but then Tutorial 5 will reinforce concepts from 1-4)
Defensive programming
- planning for eventualities that are "impossible", because you know,
  they turn out to be possible when you least expect it
    - especially as code evolves over time
</pre>


==Code==
==Code==

Latest revision as of 14:40, 8 February 2021

Video

Video from the lecture given on February 8, 2021 is now available.

Notes

Lecture 9
------------
schedule
A1 solutions
T4 via live coding

Midterm
 - midterm on March 3rd, 11:35 AM
 - review on March 1st
 - timed, 80 min, during class time
 - download PDF of midterm from cuLearn
 - upload solutions to cuLearn (via an assignment) before the end of exam period
 - open book/internet, open note, NO COLLABORATION
 - interviews afterwards to verify you understood what you said on the midterm
   - random + selected
   - you may volunteer
 - if there is clear evidence that you don't know enough to have given the answers
   you did, then I'll be talking to the Dean
 - questions on midterm are more conceptual than coding
   - do you know what is going on?
 - treat the midterm as practice for the final
   - everything you do in this class is an opportunity to raise your grade
 - midterm will all be short answer
   - some more conceptual, some based on specific code examples
   - any "code" in answers will be very short (at most 3 lines)
   - more on reading rather than writing code

Tutorial 4 is due Feb. 21st, before midnight
Assignment 2 is due Feb 26th
 - midterm is based on Assignment 1 & 2, which are based on Tutorials 1-4
 - (maybe Tutorial 5, but then Tutorial 5 will reinforce concepts from 1-4)

Defensive programming
 - planning for eventualities that are "impossible", because you know,
   they turn out to be possible when you least expect it
     - especially as code evolves over time

Code

import SwiftUI

struct ContentView: View {
    @State var c = 0
    @State var p = CGPoint(x: 0, y: 0)
    
    var body: some View {
        VStack{
            Text("Hello, you clicked \(c) times.")
                .padding()
            Image("sadDog")
                .resizable()
                .scaledToFit()
                .position(p)
                .gesture(
                    DragGesture()
                        .onEnded {_ in
                            print("Drag ended!")
                            self.p = CGPoint(x: 0, y: 0)
                        }
                        .onChanged {v in
                            self.p = v.location
                        }
                )
                .onTapGesture(count: 1, perform: {
                    c = c + 1
                })
        }
    }
}

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