Project 1 Frequently Asked Questions (FAQ) and possible answers:
1. What is MVC? Can you give an example?
Calculator program we discussed in class is a fine example of MVC. Calculator abstraction (data structures and algorithms) is realized using a set of classes in a package (model) and the user interface (graphical in this case) in a separate set of classes in a package called viewController. This helps separation of the logic and view/display user interface of an application.
2. What is an interface? Can you give an example?
We covered this lecture class on 9/6. See lectures notes for that day. There are couple example programs that were discussed. This discussion of interfaces and implementation covers from the details from the basics assuming no prior knowledge.
3. How do input and output? For example, input an integer? Output a message?
Input /output are the fundamental operations of program. There are many ways to do it. I am going to show you a simple way to input using a JOptionPane (Addition.java). This program uses Swing dialog boxes to input and output. It will work with your NGP; after all NGP is wrapper on Java Swing. You will have to import JOptionPane class, and invoke a single statement for a pop up dialog to get your input. You may also use System.out.println to output.
4. I do not how to manipulate arrays? Give an example.
This was covered during lecture on 9/4. See the array test (ArrayTest.java) example.
5. How do I start the project?
If you have not started already there is not much time to complete the project. There are two threads you can work on simultaneously: (i) the Model consisting of MineSweeper Board interface, Board class, Tile class hierarchy and Tester which can text-based or graphical , (ii) the NGP/Swing Display Board (View/Controller), and the associated reacting controller. These two talk to each other through the interface.
View/Controller passes the Tile number/coordinates and the type of click to the model. Model then process the information, updates the board on the Model side. View/Controller requests the updated information and displays it on the GUI.
The critical task on the Model-side is that of uncovering repeatedly/recursively the tiles starting from the one that was clicked. We will discuss a recursive version of this on 9/18.
6. I have completed the project, but where do I get the information for the bonus points?
You will replace the repetition control structure(s) in your current project for uncovering tiles with a recursive method. Also use a Iterator in the place of the usual indexed loop. Attend lecture on 9/18 to get more information on these two.
7. I need information on Swing. Where do I get it?
Recitations have been covering Swing for the past two weeks. java.sun.com has a fine tutorial on Swing. The Calculator and other programs we discuss also have sample code covering Swing.
8. I have the model working in a package "model", view/ controller working in a package "viewController" but these two are not able to talk to each other. More specifically when I instantiate Board class of model in my GUI, it gives me an ClassNotFound error. How to solve this problem?
Your classpath may not be set right. if your "model" package is located at /u1/csedue/name/CSE116/minesweeper, for example, you will have to include this in your classpath in your .cshrc file. For a simple java command you may add java -classpath ./:/u1/csedue/name/CSE116/minesweeper MineSweeper
where the path has to be your path to "model" package, and MineSweeper has to be your application. You may update to .emacs directory also to set the classpath, esp when you are compiling and running from inside emacs.