Вы находитесь на странице: 1из 18

TABLE OF CONTENTS

PAGE
TITLE PAGE i
TABLE OF CONTENTS ii
LIST OF FIGURES iii

I. INTRODUCTION
II. REQUIREMENTS SPECIFICATION
A. COVER LETTER
B. REQUIREMENT SPECIFICATION
III. REQUIREMENT ANALYSIS
A. USE-CASE DIAGRAM
B. CLASS DIAGRAM
C. SEQUENCE DIAGRAM
D. USER INTERFACE FORMS
IV. SYSTEM DESIGN/IMPLEMENTATION
A. SOURCE CODE LISTING
V. UNIT/SYSTEM TEST
A. QUALITY ASSURANCE CHECKLIST
VI. RECOMMENDATION
APPENDIX
1. TIMELINE/GANTT CHART
2. RESUME
I. INTRODUCTION
The Memory Game is a memory game. The game intends the player to enhance
the memory or IQ of the player. Start the memory game by selecting the right level for
you. It has three levels to choose. The Easy level is for beginners that aim to memorize
the figure within ten seconds with only three random colors. Normal level is for
intermediate players that aim to memorize the figure within five seconds with five
random colors. Hard level is for experts that aim to memorize the figure within three
seconds with seven random colors. After the time was done counting, a message box will
appear with a question. The questions will be based on the colors, names, and count given
by the memory game

II. REQUIREMENTS SPECIFICATION


A. COVERING LETTER
September 16, 2010
MR. JEREMIAS C. ESPERANZA
IT Project Head
Black Swan, Inc.

Subject: REQUIREMENT SPECIFICATION

Dear Sir:
We are glad that your organization has given us a chance to demonstrate to you the game
that we developed. Please find the attached Specification of our proposed game “The
Memory Game”.
We do hope that the deliberated specifications suit your organizational needs. If there is
any concerns and clarifications you would like to add, please feel free to contact us.

Respectfully yours,
RONNEL BALMEO
Project Manager
Bloated Mind Inc.
B. REQUIREMENT SPECIFICATION

I. Functional Requirement
1. The Memory Game will test the capability of its player to remember the
number of things they will see in the short given amount of time.
2. The Memory Game will display random number of different objects.
3. Then the game will display a question; asking the number of specific object.
4. Then the game will generate the real answer to the question.
5. The game will restart if the player wishes to (press Play again).

II. Data Requirements


1. The Memory Game will use Adobe Macro Media Flash for its interface.
2. Anyone who wishes to play the game must install the Game application first, in
order to play the game.

III. Constraints
1. Cost. The project will cost P1000.00.
2. Delivery date. The game will be in full operation on October 30, 2010.
3. Computer Hardware. Windows XP, Windows Vista, Windows 7, PC stations.
4. PC Memory Requirement. 256MB
5. Response Time. 3 seconds.
6. Programming Language to use in development. JAVA SDK 6.0, Adobe
Macro Media Flash.
7. Data volumes. The game can only host one player in every installed game
application,
8. Reliability Requirements. Mean time between failure(MTBF) should be 6
months.
IV. Guidelines
1. Main memory usage should not exceed 31,740KB.
2. The Memory Game is an application that can be installed using CD installer
provided by the game developers.

CONFORME:

JEREMIAS C. ESPERANZA RONNEL BALMEO


IT Project Head Project Manager
Black Swan Inc. Bloated Mind Inc.

III. REQUIREMENT ANALYSIS


A. USE-CASE DIAGRAM
B. CLASS DIAGRAM

C. SEQUENCE DIAGRAM
D. USER INTERFACE FORMS
IV. SYSTEM DESIGN/IMPLEMENTATION
A. SOURCE CODE LISTING
GAME
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Game extends JFrame implements Runnable, WindowListener{
private String names[];
private Color selected[];
private final Color
color[]={Color.red,Color.blue,Color.green,Color.orange,Color.yellow,Color.pink,Color.
white};
private int time;
private int cNum;
private Thread timer;
private MenuSelection menu;
public Game(MenuSelection menu,String sel,int index,int width,int height,int cNum){
super("GAME");
this.menu=menu;
this.cNum=cNum;
if(sel.equalsIgnoreCase("HARD")){
time=3;
}else if(sel.equalsIgnoreCase("NORMAL")){
time=5;
}else{
time=10;
}
names=new String[index];
selected=new Color[index];
setNames();
timer=new Thread(this,"Game");
timer.start();
setSize(width,height);
setVisible(true);
setResizable(false);
addWindowListener(this);
}
public void paint(Graphics g){
g.setColor(Color.BLACK);
g.fillRect(0, 0, 1000, 1000);
int x=20;
int y=40;
for(int index=0;index<selected.length;index++){
g.setColor(selected[index]);
if(index%4==0){
y+=70;
x=20;
}
g.fillArc(x,y, 50, 50, 0, 360);
x+=70;
}
g.setColor(Color.WHITE);
g.setFont(new Font("Arial",Font.BOLD,24));
g.drawString("Time Left: "+time, 80, 100);
}
public void run(){
try{
while(time>0){
repaint();
timer.sleep(1000);
time--;
}
}catch(Exception e){
}
setVisible(false);
Question ask=new Question(names,menu);
}
public void setNames(){
for(int index=0;index<selected.length;index++){
selected[index]=color[(int)(Math.random()*cNum)];
}
for(int index=0;index<names.length;index++){
names[index]=getName(selected[index]);
}
}
public String getName(Color color){
if(color==Color.red){
return new String("Red");
}else if(color==Color.blue){
return new String("Blue");
}else if(color==Color.green){
return new String("Green");
}else if(color==Color.yellow){
return new String("Yellow");
}else if(color==Color.orange){
return new String("Orange");
}else if(color==Color.pink){
return new String("Pink");
}else{
return new String("White");
}
}
public void windowDeactivated(WindowEvent we){
}
public void windowActivated(WindowEvent we){
this.setCursor(Cursor.WAIT_CURSOR);
}
public void windowDeiconified(WindowEvent we){
}
public void windowIconified(WindowEvent we){
}
public void windowClosed(WindowEvent we){
}
public void windowClosing(WindowEvent we){
timer.stop();
menu.setVisible(true);
}
public void windowOpened(WindowEvent we){
}
}

QUESTION
import javax.swing.*;
public class Question{
private MenuSelection menu;
private String colors[];
public Question(String colors[],MenuSelection menu){
this.menu=menu;
this.colors=colors;
int select=(int)(Math.random()*colors.length);
setAsk(select);
}
public void setAsk(int sel){
String text="How many "+colors[sel]+" colors is/are there?";
int ans=0;
for(int index=0;index<colors.length;index++){
if(colors[index].equalsIgnoreCase(colors[sel])){
ans++;
}
}
try{
int
userAns=Integer.parseInt(JOptionPane.showInputDialog(null,text,"QUESTION",JOption
Pane.QUESTION_MESSAGE));
if(userAns==ans){
JOptionPane.showMessageDialog(menu, "Correct
answer!","CONGRATZ",JOptionPane.INFORMATION_MESSAGE);
}else{
JOptionPane.showMessageDialog(menu, "Wrong answer!\nCorrect is
"+ans,"WRONG",JOptionPane.WARNING_MESSAGE);
}
}catch(Exception e){
}
menu.setIfVisible(true);
}
}

MENUSELECTION
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MenuSelection extends JFrame implements ActionListener{
private final String level[]={"EASY","NORMAL","HARD"};
private JButton startGame;
private JButton instructionOfTheGame;
private JButton exitGame;
private JComboBox select;
public MenuSelection(){
super("MENU");
setMenuButtons();
select = new JComboBox(level);
select.setSelectedItem("EASY");
JPanel menuPanel=new JPanel();
menuPanel.setLayout(new GridLayout(4,1));
menuPanel.add(startGame);
JPanel lvlPanel=new JPanel();
lvlPanel.setLayout(new GridLayout(1,2));
lvlPanel.add(new JLabel(" LEVEL SELECTION"));
lvlPanel.add(select);
menuPanel.add(lvlPanel);
menuPanel.add(instructionOfTheGame);
menuPanel.add(exitGame);
getContentPane().add(menuPanel,BorderLayout.SOUTH);
addMouseListener(new Handler(this));
setSize(300,500);
setIfVisible(true);
}
public void paint(Graphics g){
Color
color[]={Color.red,Color.blue,Color.GREEN,Color.orange,Color.yellow,Color.pink};
g.setColor(Color.BLACK);
g.fillRect(0, 0, 500, 393);
for(int x=0;x<100;x++){
g.setColor(color[(int)(Math.random()*6)]);
g.fillArc((int)(Math.random()*500), (int)(Math.random()*353), 40, 40, 0, 360);
}
g.setColor(Color.WHITE);
g.setFont(new Font("Arial Black",Font.BOLD,40));
g.drawString("MEMORY", 45, 180);
g.drawString("GAME", 80, 230);
}
public void setIfVisible(boolean condition){
setVisible(condition);
setResizable(false);
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource()==startGame){
int width=300;
int height=380;
int many=16;
int cNum=3;
if(level[select.getSelectedIndex()].equalsIgnoreCase("HARD")){
many=24;
height=520;
cNum=7;
}else if(level[select.getSelectedIndex()].equalsIgnoreCase("NORMAL")){
many=20;
height=450;
cNum=5;
}
Game game=new Game(this,level[select.getSelectedIndex()],many,width,height,cNum);
setVisible(false);
}else if(ae.getSource()==instructionOfTheGame){
showIns();
}else if(ae.getSource()==exitGame){
if(JOptionPane.showConfirmDialog(this, "Quit Game?", "HELP",
JOptionPane.YES_NO_OPTION)==0){
System.exit(0);
}
}
}
public void setMenuButtons(){
startGame=new JButton("START GAME");
instructionOfTheGame=new JButton("INSTRUCTION");
exitGame=new JButton("QUIT");
startGame.addActionListener(this);
instructionOfTheGame.addActionListener(this);
exitGame.addActionListener(this);
startGame.setMnemonic('s');
instructionOfTheGame.setMnemonic('c');
exitGame.setMnemonic('q');
}
public void showIns(){
String text="Start the game by selecting the right" +
"\nlevel for you. Easy level is for beginners" +
"\nthat aims to memorize the figure within" +
"\n10 seconds with only 3 random colors." +
"\nNormal level is for intermediate players" +
"\nthat aims to memorize the figure within" +
"\n5 seconds with 5 random colors. Hard level" +
"\nis for experts that aims to memorize the" +
"\nfigure within 3 seconds with 7 random" +
"\ncolors. The question will be based on the" +
"\ncolors name and count.";
JTextArea out=new JTextArea(text,7,22);
out.setEditable(false);
JOptionPane.showMessageDialog(this, new
JScrollPane(out),"INSTRUCTION",JOptionPane.INFORMATION_MESSAGE);
}
private class Handler extends MouseAdapter{
private MenuSelection menu;
public Handler(MenuSelection menu){
this.menu=menu;
}
public void mouseClicked(MouseEvent me){
if(me.isMetaDown()){
JOptionPane.showMessageDialog(menu, "Created by Mandilag,Balmeo,Davis,Anilao",
"ABOUT", JOptionPane.INFORMATION_MESSAGE);
}
}
}

MAIN
import javax.swing.*;
public class Main{
public static void main(String[] args)throws Exception{
MenuSelection application=new MenuSelection();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
while(true){
Thread.sleep(120);
application.repaint();
}
}
}

V. UNIT/SYSTEM TEST
A. QUALITY ASSURANCE CHECKLIST
VI. RECOMMENDATION
APPENDIX
1. TIMELINE/GANTT CHART
2. RESUME

Вам также может понравиться