Download presentation
Presentation is loading. Please wait.
Published byBertram Wells Modified over 9 years ago
1
Clicker questions 11/21/13 CSE 1102 Fall 2013
2
neighbors, (i,j) = (2,2) [0][0] [i][j]
3
neighbors, (i,j) [i][j]
4
neighbors, (i,j) = (1,0) [i][j] X X X
6
A. It sends the model updateGame messages when needed B. It sets cells in the model to be either alive or dead C. It queries the model whether cells are alive or dead D. It tells the model to display its contents E. More than one of the above is true This diagram indicates that LifeView "knows about" LifeModel. According to the program writeup, what does the view do to the model when the animation is running?
7
A. It sends the model updateGame messages when needed B. It sets cells in the model to be either alive or dead C. It queries the model whether cells are alive or dead D. It tells the view to display its contents E. More than one of the above is true This diagram indicates that LifeController "knows about" LifeModel and LifeView. According to the program writeup, what does the controller do when the animation is running?
8
1. actionPerformed(ActionEvent) timer to controller 2. updateGame() controller to model 3. repaint() controller to view 4. isCellAlive(int,int) view to model Summarizing: during animations isCellAlive(int,int) repaint() updateGame() actionPerformed(ActionEvent)
9
A. It sends the model updateGame messages when needed B. It sets cells in the model to be either alive or dead C. It queries the model whether cells are alive or dead D. It tells the model to display its contents E. More than one of the above is true This diagram indicates that LifeView "knows about" LifeModel. According to the program writeup (and consistent with the GameModel interface), what does the view do to the model when the animation is not running?
10
A. It sends the model updateGame messages when needed B. It sets cells in the model to be either alive or dead C. It queries the model whether cells are alive or dead D. It tells the view to display its contents E. None of the above is true This diagram indicates that LifeController "knows about" LifeModel, LifeView and Timer. According to the program writeup, what does the controller do when the animation is not running?
11
A. getIoPanel(); B. startAnimation(); C. stopAnimation(); D. All of the above E. B or C above This diagram indicates that AnimationButton "knows about" LifeController. What message(s) does the AnimationButton send to the LifeController?
12
A. It sends a message to the Timer B. It sends a message to the LifeView C. It doesn't send any messages D. Two of the above could be true E. None of the above What does the LifeController do when it receives a startAnimation() message?
14
one button…or two?
15
So what's next? Introduction to data structures Two Perspectives: Abstract description (capabilities) Implementation(s) For structures: Stack Queue List Dictionary
16
Abstract Data Types (1970s) Description of a data structure that includes only its operations, not its implementation In Java, ADTs are best modeled by interfaces
17
Example: Stack Operations: push(element) – adds element to "top" of the stack pop – returns the top element of the stack, which is removed from the stack peek – returns the top element of the stack without changing the stack isEmpty – returns true if stack is empty, false otherwise
18
Stack intuitions examples in the world uses in computing
19
A. "Finland" B. "is" C. "my" D. "home" E. None of the above Suppose I have a stack S that can store Strings, and I execute the following statements starting with an empty stack : 1. S.push("Finland"); 2. S.push("is"); 3. S.push("my"); 4. String w = S.peek(); 5. String x = S.pop(); 6. S.push("home"); 7. String y = S.pop(); 8. String z = S.pop(); What is the value of z?
20
A. "Iceland" B. "cool" C. true D. false E. None of the above Suppose I have a stack S that can store Strings, and I execute the following statements starting with an empty stack : 1. S.push("Iceland"); 2. S.push("is"); 3. String w = S.peek(); 4. String x = S.pop(); 5. S.push("cool"); 6. String y = S.pop(); 7. boolean z = S.isEmpty(); What is the value of z?
21
Example: Queue Operations: enqueue(element) – adds element to "back" of the queue dequeue – returns the "front" element of the queue, which is removed from the queue front – returns the front element of the queue without changing the queue isEmpty – returns true if queue is empty, false otherwise
22
Queue intuitions examples in the world uses in computing
23
A. "Sweden" B. "is" C. "my" D. "neighbor" E. None of the above Suppose I have a queue Q that can store Strings, and I execute the following statements starting with an empty queue : 1. Q.enqueue("Sweden"); 2. Q.enqueue("is"); 3. Q.enqueue("my"); 4. String w = Q.dequeue(); 5. String x = Q.peek(); 6. Q.enqueue("neighbor"); 7. String y = Q.dequeue(); 8. String z = Q.dequeue(); What is the value of z?
24
The country with the red star on it is: A. Canada B. Sweden C. Latvia D. Finland E. None of the above
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.