CSCI 1320 - Assignment #5


For this assignment I'm going to give you some fairly short and sweet problems that mainly test your ability to work with files. They will each also involve something with arrays, pointers, or pass-by-reference.

Basic Editor:

My first programming experience was with the BASIC programming language in the original line-numbered format. I want you to write a program that does the beginnings of a BASIC environment. There are only 5 "commands" you have to handle.

If the user types in a line that begins with a number, that should be seen as a line number for a line of code. You'll want to store the line and the number.

The "save <filename>" command will save the "program" to the specified file as text.

The "load <filename>" command should load in a "program" from the specified text file.

The "list" command should print the program to screen (very like save but to standard out instead of a file).

The "quit" command terminates the program.

When you list a program it should be displayed in sorted order by line number. See the sample input and output for examples. No line will be more than 80 characters and you only have to handle 100 lines at most. In addition to atoi, you might find the strcmp and strcpy functions helpful for this assignment. Use man to see what they do. You can use gets for reading full lines or use fgets and pass it stdin if you don't want to see warnings.

input : output : saved file

Matrix Math:

This problem will have you playing with some matrices. It will lead into code later on that will solve the chemical equations if you did the chemistry option in assignment #4. Your program will handle two NxN matrices, we'll call them A and B, and it should have the following menu options. The matrices will never be bigger than 10x10.

1. Enter matrix size.

2. Enter matrix A.

3. Enter matrix B.

4. Write matrices to file.

5. Read matrices from file.

6. Print sum of matrices.

7. Print product of matrices.

8. Quit

The output file should be a text file where the first line has the matrix size, N. that is followed by N lines, each with N numbers giving the A matrix and after that are N lines with N numbers giving the B matrix.

For extra credit, you can have this program use a GUI and use the Table component to display the matrices. If you do this, the options will be a bit different and they should probably be menu items.

input : output : saved file

Minesweeper:

Write a GUI for doing Minesweeper. For basic credit, you need a to have the grid and make it clickable so that you see a blank, a number, or a mine as is appropriate for minesweeper. This program should run as a script and the board should be on a window that pops up automatically when you run the script.

There are two options for getting extra credit on this. The first is to have it so that when you click on a square that is "blank", it will automatically clear all the connected blank squares. The second is to add a high-scores board. This will use a file so that the high scores are saved from one run to the next. The score should be based on how long it takes the user to complete the board.

Memory:

This option has you write a game of memory. There is a grid of "cards". The game start off with you seeing the back of the cards. You can click a card to flip it over. After you clikc two cards one of two things will happen. If the cards match, then they will both disappear. If they don't match then they flip back over and you lose a turn. The goal is to find all the matches before you run out of turns.

The only extra credit for this option is a high score board based on the amount of time taken and the number of turns left over when you complete the board.

Paint:

For this option you will write a simple paint program. The program should at least have options for drawing lines, rectangles, and ellipses and picking colors. If you pick this option you should come talk to me about how to get a javax.swing.JColorChooser into your GUI.

Dinosaur:

This option is the beginning of a graphical game. You will have multiple images of dinosaurs that move around on a window. One of them should be controlled by either the arrow keys or the mouse. Use your imagination. (If you don't like dinosaurs pick something else. The real goal is sprite based graphics that are controlled by the user with mouse or keyboard input.)

Map Building GUI:

This was suggested by a student so don't blame me that this one is going to be a fair bit harder than any of the others. The idea is to write a GUI for editing the maps that were used in the Map Traversal option of assignment #4. I'll let you decide what that looks like.

Data Plotting:

For this option you will write some code to do very simple scatter plots. I'd like to have it so that you write a script that is called with one or more files as command line arguments. The script should pop up a frame that will show a scatter plot of the data different files. Ideally each file should be drawn in a different color with lines between the data points. You should handle files that have the data elements separated by spaces.

There are several options for extra credit on this. First is to make your program also handle CSV files. You can have the script decide if it should do CSV parsing or space delimited based on the file extension. A second extra credit option is to put axes on the plot. The normal version can just use the entire window area as the bounds of the plot. If you do this, you will have to leave a buffer region where the ticks and values are displayed and the points and lines go inside of the inner area.