44
CS 304 Project Kirk Scott 1

CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

Embed Size (px)

Citation preview

Page 1: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

1

CS 304 Project

Kirk Scott

Page 2: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

2

• 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.

Page 3: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

3

Introductory Information

Page 4: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

4

• 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.

Page 5: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

5

• 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.

Page 6: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

6

• 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.

Page 7: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

7

• 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.

Page 8: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

8

• 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.

Page 9: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

9

• 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.

Page 10: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

10

• 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.

Page 11: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

11

• 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.

Page 12: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

12

• 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.

Page 13: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

13

• 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.

Page 14: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

14

• 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.

Page 15: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

15

• 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.

Page 16: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

16

Part 1

Page 17: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

17

• Part 1 consists of making a simple editor. • See the items below.

Page 18: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

18

• 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.

Page 19: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

19

• 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.

Page 20: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

20

• 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.

Page 21: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

21

• 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:

Page 22: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

22

Keyword specifying player. One of the following:PlayerContestantEntrantSide

Keyword specifying which cup to play. One of the following:CupMovePlay

Page 23: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

23

• 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".

Page 24: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

24

• 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• …

Page 25: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

25

• 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.

Page 26: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

26

• 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.

Page 27: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

27

• Total points for Part 1: 40.

Page 28: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

28

Part 2

Page 29: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

29

• 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.

Page 30: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

30

• 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.

Page 31: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

31

• 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.

Page 32: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

32

• 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.

Page 33: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

33

• 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.

Page 34: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

34

• 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.

Page 35: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

35

• 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.

Page 36: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

36

• 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.

Page 37: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

37

• Total points for Part 2: 80.

Page 38: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

38

Part 3

Page 39: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

39

• 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.

Page 40: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

40

• 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.

Page 41: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

41

• 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.

Page 42: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

42

• 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.

Page 43: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

43

• Total point breakdown:• Part 1: 40• Part 2: 80• Part 3: 20• ----• Total: 140

Page 44: CS 304 Project Kirk Scott 1. The specifications for this project will be subject to possible minor revision as the semester progresses depending on what

44

The End