Presentation is loading. Please wait.

Presentation is loading. Please wait.

Clicker questions 11/14/13 CSE 1102 Fall 2013. A. Composite B. Holder C. Proxy D. Factory E. Impossible to tell from diagram In this example, we want.

Similar presentations


Presentation on theme: "Clicker questions 11/14/13 CSE 1102 Fall 2013. A. Composite B. Holder C. Proxy D. Factory E. Impossible to tell from diagram In this example, we want."— Presentation transcript:

1 Clicker questions 11/14/13 CSE 1102 Fall 2013

2 A. Composite B. Holder C. Proxy D. Factory E. Impossible to tell from diagram In this example, we want to be able to control the current Car using MoveButtons, an XSlider, and a YSlider. Which design pattern does this UML illustrate?

3 A.A Proxy has all of the methods associated with the Class it models, Holder does not B.A Holder can be associated with many classes that want to access it; a Proxy can only be accessed by 1 class C.The contents of a Holder can change, the contents of a proxy are fixed at instantiation time D.The contents of a Proxy can change, the contents of a Holder are fixed at instantiation time E.None of the above is the primary difference Both Holder and Proxy allow us to model something. The primary difference between the two is

4 Why does SpeedListener have a SpeedSlider _slider set in its constructor? A.The SpeedListener can work with multiple sliders. B.The code is clearer, as this is hard to sort out C.We want to distinguish between the Accelerator and the SpeedSlider D.The SpeedListener needs to refer to its enclosing SpeedSlider. E.None of the above is true 1.public class SpeedSlider extends javax.swing.JSlider{ 2. private Accelerator _accelerator; 3. public SpeedSlider(int anOrientation, Accelerator anAccelerator, 4. int aMinSpeed, int aMaxSpeed, int aCurrentSpeed){ 5. super(anOrientation, aMinSpeed, aMaxSpeed, aCurrentSpeed); 6. _accelerator = anAccelerator; 7.... 8. this.addChangeListener(new SpeedListener(this)); 9. } 10. private class SpeedListener implements ChangeListener { 11. private SpeedSlider _slider; 12. public SpeedListener(SpeedSlider aSlider){ 13. _slider = aSlider; 14. } 15. public void stateChanged(ChangeEvent e) { 16. _accelerator.setValue(_slider.getValue()),_slider.getValue()); 17. } } }

5 Time public class Time { private int _hours; private int _minutes; private int _seconds; public Time(int h, int m, int s) { _hours = h; _minutes = m; _seconds = s; }

6 Tasks public void tick(); public int compareTo(Time otherTime); public int add (Time offset); public int subtract(Time offset);

7 What's up with this? A.A program that will showcase my mad Java skills B.The next CSE 1102 assignment C.A program that can compute anything that is computable D.A game that swept the world in the 1970s E.All of the above

8 The game Played on 2-d rectangular grid of cells A cell can be either alive or dead States (or generations) are sequential: each state is determined by rules applied to predecessor

9 The rules Any live cell with fewer than two live neighbors dies, as if caused by under-population. Any live cell with two or three live neighbors lives on to the next generation. Any live cell with more than three live neighbors dies, as if by overcrowding. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.

10 A cell can have 8 neighbors

11 (demo)

12 Model-View-Controller A structure for controlling on-screen things Model: contains the data to be displayed View: displays the data on the screen Controller: takes user input, makes changes to Model


Download ppt "Clicker questions 11/14/13 CSE 1102 Fall 2013. A. Composite B. Holder C. Proxy D. Factory E. Impossible to tell from diagram In this example, we want."

Similar presentations


Ads by Google