24
Clicker questions 11/21/13 CSE 1102 Fall 2013

Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

Embed Size (px)

Citation preview

Page 1: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

Clicker questions11/21/13

CSE 1102 Fall 2013

Page 2: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

neighbors, (i,j) = (2,2)

[0][0]

[i][j]

Page 3: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

neighbors, (i,j)

[i][j]

Page 4: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

neighbors, (i,j) = (1,0)

[i][j]

X

X

X

Page 5: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]
Page 6: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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?

Page 7: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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?

Page 8: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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)

Page 9: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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?

Page 10: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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?

Page 11: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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?

Page 12: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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?

Page 13: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]
Page 14: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

one button… or two?

Page 15: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

So what's next?Introduction to data structures

Two Perspectives:

• Abstract description (capabilities)

• Implementation(s)

For structures:

• Stack

• Queue

• List

• Dictionary

Page 16: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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

Page 17: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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

Page 18: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

Stack

• intuitions

• examples in the world

• uses in computing

Page 19: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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?

Page 20: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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?

Page 21: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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

Page 22: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

Queue

• intuitions

• examples in the world

• uses in computing

Page 23: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

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?

Page 24: Clicker questions 11/21/13 CSE 1102 Fall 2013. neighbors, (i,j) = (2,2) [0][0] [i][j]

The country with the red star on it is:

A. Canada

B. Sweden

C. Latvia

D. Finland

E. None of the above