450 likes | 570 Views
CS 304 Project. Kirk Scott. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what happens. Changes will be announced in class and the online document will be updated to reflect them.
E N D
CS 304 Project Kirk Scott
The specifications for this project will be subject to possible minor revision as the semester progresses depending on what happens. • Changes will be announced in class and the online document will be updated to reflect them. • The overall nature of the project will not change.
This project is not tied directly to design patterns per se. • One particular design pattern does appear, but otherwise the project is simply an extended exercise in programming without patterns appearing or needing to be used.
The general idea is that it's good to practice programming even if you aren't applying patterns. • And even if you aren't applying patterns, having learned about them will tend to make you a more perceptive programmer.
In all parts of the project, the graphical user interface is the choice of the student. • In other words, you are welcome to use menus, buttons, or any other graphical feature. • Some graphical objects may be more obvious choices than others. • There is no penalty for taking the "easy" route. • It is advisable.
No matter what choices you make, in the end you will have to document/demonstrate/present your project in such a way that it is apparent to me how things work so that I can easily check off the points you've earned.
The project is based on the game of Wari as presented in CS 202. • The rules of play are simplified: • All that has to happen is that a capture occur when the last seed played goes into a cup containing 1 or 2 seeds.
Each student will be given separate specifications for the project. • These specifications include the number of cups, the number of seeds, and other parameters. • The range of specifications will be outlined where appropriate in the points below.
The project falls into three major parts, with several subparts. • The first two parts can be developed separately. • The third part brings the first two together.
The first part is essentially a small editor designed to edit "game program" files which spell out the moves of a Wari game. • The second part is a program that plays such a Wari game program and displays the course of the game on the screen graphically. • The third part consists of those changes to both pieces of code so that you can invoke the player from the editor. • The parts will be given below with their subparts and the points assigned to them.
Here is a final bit of introductory information. • You may or may not recall that in CS 202 I frequently said that successful programming consists of inspired copying. • Concerns about academic integrity should dissuade you from wholesale copying, but it is common programming practice to find partial solutions to problems and modify them for your own use.
In CS 202 I tried to encourage people to use the Java API because that is a ready source of information. • In CS 304, I want to suggest the following to you: • You will not find complete solutions to the programming project anywhere online, so that's not an option anyway. • The project does include elements that will not be covered or explained in class, and no example code will be given which solves these problems. • However, don't despair; you're not alone.
It's time to branch out and accept the fact that when programming on your own, you will find answers online. • When I have programming questions I typically do a Web search before even consulting the book selected for the class. • Your fellow students and professional programmers have found those sites which are most helpful for Java programming.
I encourage you to find these sites and use them. • By the way, the two items in the project that come to mind where this might be particularly helpful are these: • Highlighting a single line in a text area; • and calling one Java program from another. • It is quite possible that you'll find online help useful for other parts of the project too.
Part 1 consists of making a simple editor. • See the items below.
1. 10 points. • Create a simple editor with save and load functions. • Note that the Java API includes a JEditorPane class. • You are welcome to use this and any other ready-made classes that make your work easier.
2. 10 points. • Add the function to your editor to specify a file type, namely "wari". • If you choose this type for your file, it should receive the extension ".wari" by default when saved. • It may be possible to do this using characteristics of the JFileChooser or related classes. • If so, feel free. • Otherwise, implement the functionality using your own logic. • 5 points.
Also, if you choose the file type, from that point on, the text entered into the editor should appear in a color different from black. • There will be three choices for color: • Something in the purple-red range, something in the orange-yellow range, or something in the blue-green range. • You may use system supplied colors. • You may also create a custom color if you want to. • 5 points.
3. 10 points. • Your editor should have auto-completion for Wari program files. • The "language" for Wari programs will have two keywords, one to specify the player, the other to specify the cup to be played. • In the specifications, there will be different options for these. • They are as follows:
Take the combination of keywords Player/Cup for example. • The idea is that if the user is typing into the editor and enters the letter "P", the editor should auto-complete the word to "Player". • Likewise, if the user enters "C", the editor should auto-complete the word to "Cup".
The program file for a game would take this form: • Player 1 Cup 1 • Player 2 Cup 4 • Player 1 Cup 7 • Player 2 Cup 3 • …
As with the graphical user interface, it will be your choice whether to separate items with white space, commas, or no space at all. • This will become a concern when implementing the game player. • That program will have to be designed to read and interpret Wari program files as they are created in the editor program.
4. 10 points. • The editor should have undo and redo functionality. • It will be your decision whether these will be character-by-character or whether auto-completed keywords are the unit of work. • Either one is equally good. • As usual, you just have to make it clear what you did so that I can effectively check it. • Note that this functionality is related to a design pattern: Memento.
Part 2 consists of creating a Wari game program player with a graphical representation. • This will have similarities with Wari as given in CS 202, but there are significant differences in functionality.
The basic situation is this: • You don't play the game by interacting with the interface. • The game is played by loading a game program, which the player knows how to read and execute, and the game player displays the results graphically.
1. 10 points. • Cups and seeds should be graphically represented in the player. • The different specifications for students will be along the lines of those in CS 202. • In other words, you will be told how many cups for each side of the game and how many seeds initially in each cup.
2. 20 points. • The game player should have a text area which shows the loaded game program. • 10 points. • It should have load functionality which will open a Wari program file, load it into some dynamic structure in the game player program, and display it in the text area. • 10 points.
3. 30 points. • This numbered item is the heart of the game playing program. • The player should have an option to play the loaded game. • 10 points. • There is no need to introduce any delays to show play progressing at a speed perceptible to a human observer, but the end results of taking the game playing option should be the completed game displayed in the cups on the screen. • 10 points.
Playing the game consists of looping through the loaded program, interpreting the plays or instructions in it, and executing them. • This is a significant change from any previous versions of Wari. • A non-Wari program that has functionality similar to this will be posted on the course Web page for your reference in understanding what this means and how you might implement it. • 10 points.
4. 20 points. • There should be an additional option in the player called the step function. • This means that for every click of the button or selection of the menu item or whatever graphical item represents this functionality, just one game program move will be read and executed, and the results of that one move will be displayed graphically. • In other words, it will be possible to follow the progress of a game step-by-step or move-by-move, one player after the other. • 10 points.
The current instruction should be highlighted in the text area showing the complete program by using a different background color or text color. • 10 points.
Part 3 links parts 1 and 2 together. • As such, it involves aspects of both of the other parts. • There is only 1 numbered item because part 3 either works or doesn't work, but the item involves several different ideas.
1. 20 points. • The editor of part 1 should have an option to "play" the program that is currently open in it. • This should effectively require that any changes in the editor be saved in the file before going further. • Then, it should trigger what is more or less a native call to the player of part 2. • In other words, one program invokes the other.
From the Wari game point of view, it is apparent that the player should be written to accept a game program using the keywords that the editor auto-completes when writing a game program. • The player program should be written so that it will accept a game program file as a command line argument. • When the editor calls the player, it should send as an argument the name of the currently open game program file that has just been saved.
For the purposes of this project, it is sufficient that taking the option in the menu opens the game player and loads the game program file. • It does not have to cause the game program to run. • With the player open, it is then up to the user to either run the game program or step through it.
Total point breakdown: • Part 1: 40 • Part 2: 80 • Part 3: 20 • ---- • Total: 140