cs176:501b:review_of_java_basics_ides_intro_to_two-dimensional_arrays
Table of Contents
Review of Java Basics, IDEs, Intro to Two-Dimensional Arrays
Review of Java Basics (with an intro to IDEs)
- Integrated Development Environments
- Recommended link: http://www.leepoint.net/notes-java/tools/10ide.html
- Advantages over using simple text editors plus command line:
- (Usually) Single environment for the program development cycle: editing, compiling, running/debugging programs
- Visual error reporting
- Many to choose from
- Simple IDEs
- Used in education, beginning programming
- Today, we will use BlueJ.
- Advanced IDEs
- Used by “real” developers
- Support large projects
- Collaboration features
- Support for multiple programming languages
- Support for GUI building
Lab Activity: Run bluej and try editing, compiling and running Java programs
- Login to Linux in HH 310.
- Start a Terminal in Linux.
- Create the “cs176” or “cs501b” folder, which will hold all your work for this course.
- Start bluej in the Terminal.
- Write a save a simple program.
Introduction to Two-Dimensional Arrays
- Recommended link: http://www.fredosaurus.com/notes-java/data/arrays/arrays-2D.html
- Lab Activity: Try writing a simple program that uses a 2-D array to store and print the following array of stars (asterisks):
***** * * *****
Example Application of Two-Dimensional Arrays: Minesweeper
- If you don't know what minesweeper is, see Wikipedia.
- You can also play a version of the game online at http://www.chezpoor.com/minesweeper/minesweeper.html.
- What follows are some screens from a simple text-mode version of minesweeper.
:) 1 2 3 4 5 6 7 8 9 -- -- -- -- -- -- -- -- -- 1 | - - - - - - - - - 2 | - - - - - - - - - 3 | - - - - - - - - - 4 | - - - - - - - - - 5 | - - - - - - - - - 6 | - - - - - - - - - 7 | - - - - - - - - - 8 | - - - - - - - - - 9 | - - - - - - - - - Enter a command to perform, where command is one of: 'o' to open a square 'f' to mark a square with a flag (F) '?' to mark a square with a question mark (?) 'c' to clear a square 'q' to quit the game Enter a command ( <o,f,?,c,q> ): o Enter row & column coordinates of square separated by a space: 2 2 :) 1 2 3 4 5 6 7 8 9 -- -- -- -- -- -- -- -- -- 1 | - - - - - - - - - 2 | - 4 - - - - - - - 3 | - - - - - - - - - 4 | - - - - - - - - - 5 | - - - - - - - - - 6 | - - - - - - - - - 7 | - - - - - - - - - 8 | - - - - - - - - - 9 | - - - - - - - - -
- Basic functionality:
- Creation of program grid
- Setting of randomly placed mines, computation of numbers in unmined squares
- Drawing of user interface
- Opening and displaying of grid squares specified by player
- Setting of flags and question marks on grid squares specified by player
- Advanced functionality:
- Checking if the last move has won or lost the game
- Clearing all surrounding unmined squares when an unmined square is opened
- How might this be programmed?
- Assuming this will involve two-dimensional arrays, how would the array (or arrays) be used?
cs176/501b/review_of_java_basics_ides_intro_to_two-dimensional_arrays.txt · Last modified: 2015/04/24 13:47 by jchung