Upload
bertram-wells
View
218
Download
0
Tags:
Embed Size (px)
Citation preview
Clicker questions11/21/13
CSE 1102 Fall 2013
neighbors, (i,j) = (2,2)
[0][0]
[i][j]
neighbors, (i,j)
[i][j]
neighbors, (i,j) = (1,0)
[i][j]
X
X
X
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?
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?
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)
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?
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?
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?
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?
one button… or two?
So what's next?Introduction to data structures
Two Perspectives:
• Abstract description (capabilities)
• Implementation(s)
For structures:
• Stack
• Queue
• List
• Dictionary
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
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
Stack
• intuitions
• examples in the world
• uses in computing
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?
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?
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
Queue
• intuitions
• examples in the world
• uses in computing
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?
The country with the red star on it is:
A. Canada
B. Sweden
C. Latvia
D. Finland
E. None of the above