0% found this document useful (0 votes)
19 views31 pages

OOP Project 5

The document outlines a project on the Rock, Paper, Scissors game developed by Md. Badrul Alom as part of his coursework for a Bachelor of Science in Computer Science and Engineering. It includes recommendations, declarations, approvals, acknowledgments, and an abstract detailing the game's implementation using Java Swing, focusing on GUI design and event-driven programming. The project serves as an educational tool for beginners in programming, enhancing their understanding of GUI development and logical thinking.

Uploaded by

mdsharifalom95
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views31 pages

OOP Project 5

The document outlines a project on the Rock, Paper, Scissors game developed by Md. Badrul Alom as part of his coursework for a Bachelor of Science in Computer Science and Engineering. It includes recommendations, declarations, approvals, acknowledgments, and an abstract detailing the game's implementation using Java Swing, focusing on GUI design and event-driven programming. The project serves as an educational tool for beginners in programming, enhancing their understanding of GUI development and logical thinking.

Uploaded by

mdsharifalom95
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PROJECT ON

ROCK, PAPER, SCISSORS, GAME.

"A project prepared as a partial requirement for the 4th semester


coursework in Computer Science and Engineering."

Submitted By
Md: Badrul Alom
ID: 0592320105101023
Bathch: 29th.Department of CSE
Z. H. Sikder University of Science and
Technology
Submitted To
Md. Rafiul Islam
Lecturer, Department of CSE
Z. H. Sikder University of Science and
Technology

©Z. H. Sikder University of Science and Technology


Page |I

Recommendation
The project entitled
“Rock, Paper, Scissors, Game”
submitted by Md. Badrul Alom (ID: 0592320105101023) has been
examined and found satisfactory. The project demonstrates a clear
understanding of fundamental programming concepts and basic software
development practices.

It is, therefore, recommended for acceptance as a part of the coursework


requirement for the 4th semester of the Bachelor of Science in
Computer Science and Engineering (B.Sc. Engg.) program.

Supervisor
Md. Rafiul Islam
Lecturer,
Department of Computer Science and Engineering
Z. H. Sikder University of Science and Technology

©Z. H. Sikder University of Science and Technology


P a g e | II

Declaration
I hereby declare that the project work entitled “Rock, Paper,
Scissors,Game”submitted to Z.H. Shikder University of Science
andTechnology, is a record of my original work carried out under
the guidance of Md. Rafiul Islam and that this report has not
beensubmitted previously for the award of any degree, diploma,
fellowship, or other similar titles to any other university or institution. I
further declare that all sources of information used in this project have
been duly acknowledged.

(Signature)
Md. Badrul Alom
ID: 0592320105101023
Batch: 29th.
Department of Computer Science and Engineering
Z.H. Shikder University of Science and Technology

©Z. H. Sikder University of Science and Technology


P a g e | III

Approval
Approval (For 4th Semester Project)
This is to certify that the project entitled "Rock Paper Scissors Game
using Java", submitted by Md. Badrul Alom, Student ID:
0592320105101023 as a part of the academic requirements of the
4th semester in the Bachelor of Science in Computer Science and
Engineering (B.Sc. in CSE) program, has been carried out under my
supervision.The work is found to be satisfactory and is hereby approved
for submission.

Supervisor
Md. Rafiul Islam
Lecturer,
Department of Computer Science and Engineering
Z. H. Sikder University of Science and Technology

©Z. H. Sikder University of Science and Technology


P a g e | IV

Certification
This is to certify that the project report titled “Rock Paper Scissors Game
using Java” has been carried out by Md. Badrul Alom, bearing Student
ID: 0592320105101023,under my supervision as a part of the academic
requirements of the 4th semester in the Bachelor of Science in
Computer Science and Engineering (B.Sc. in CSE) program.

The work embodied in this report is original and has not been submitted
to any other institution or university for the award of any degree or
diploma.

Supervisor
Md. Rafiul Islam
Lecturer,
Department of Computer Science and Engineering
Z. H. Sikder University of Science and Technology

©Z. H. Sikder University of Science and Technology


Page |V

Acknowledgement

First and foremost, I would like to express my deepest gratitude to the


Almighty for granting me the strength, patience, and knowledge to
successfully complete this project.
I am sincerely thankful to my respected teacher and project supervisor,
Md. Rafiul Islam, for their continuous guidance, valuable suggestions,
and constant encouragement throughout the development of this project.
Without their expert supervision and support, this work would not have
been possible.
I would also like to thank our department and institution, Department
of Computer Science and Engineering, Z. H. Sikder University of
Science and Technology , for providing the necessary resources, a
conducive learning environment, and motivation for conducting such an
engaging and practical project.
A special thanks to my classmates, friends who supported me directly and
indirectly, shared ideas, and helped me overcome difficulties during the
project.
Finally, I want to acknowledge all the online resources, documentation,
and platforms (like StackOverflow, Java Documentation, W3Schools,
etc.) that have been incredibly helpful during the coding and debugging
process of this Rock, Paper, Scissors Game using Java GUI and AI logic.

Md: Badrul Alom


ID: 0592320105101023
Bathch: 29th
[Date]

©Z. H. Sikder University of Science and Technology


P a g e | VI

Abstract
This project implements a classic Rock, Paper, Scissors game using Java
Swing for the graphical user interface. The game allows a user to play
against the computer, where the computer’s choices are generated
randomly. The application keeps track of scores for both the player and
the computer and displays the results along with appropriate images
representing each choice and the game outcome. The interface is designed
to be user-friendly, with clear buttons for selecting moves and options to
start, exit, or return to the main menu. This project demonstrates basic
event-driven programming, GUI design, and simple game logic
implementation in Java. It serves as an educational example for beginners
learning Java GUI development and interactive programming.

©Z. H. Sikder University of Science and Technology


P a g e | VII

Contents
Recommendation.......................................................................................................................................... I
Declaration................................................................................................................................................... II
Approval ..................................................................................................................................................... III
Certification ................................................................................................................................................ IV
Acknowledgement ....................................................................................................................................... V
Abstract....................................................................................................................................................... VI
List of Figures and Tables ......................................................................................................................... IX
Chapter 1: Introduction ............................................................................................................................. 1
1.1 Background of the Study ............................................................................................................ 1
1.2 Problem Statement...................................................................................................................... 1
1.3 Objectives of the Study ............................................................................................................... 1
1.4 Scope of the Project..................................................................................................................... 1
1.5 Significance of the Study ............................................................................................................ 2
1.6 Methodology ................................................................................................................................ 2
1.7 Features of the Project ................................................................................................................ 2
1.8 Social Impact ............................................................................................................................... 2
Chapter 2: Literature Review .................................................................................................................... 3
2.1 Introduction to Literature Review ............................................................................................ 3
2.2 Previous Studies .......................................................................................................................... 3
2.3 Theoretical Framework .............................................................................................................. 3
2.4 Comparison of Existing Methods / Technologies ..................................................................... 4
2.5 Research Gaps and Limitations ................................................................................................. 4
Chapter 3: System Analysis ....................................................................................................................... 5
3.1 Introduction ................................................................................................................................. 5
3.2 System Overview ......................................................................................................................... 5
3.3 Functional Requirements ........................................................................................................... 6
3.4 Non-Functional Requirements ................................................................................................... 6
3.5 Use Case Diagram ....................................................................................................................... 7
3.6 Data Flow Diagram (DFD) ......................................................................................................... 7
Chapter 4: Methodology............................................................................................................................. 9

©Z. H. Sikder University of Science and Technology


P a g e | VIII

4.1 Requirement Analysis ................................................................................................................. 9


4.2 System Design ............................................................................................................................ 10
4.3 Implementation ......................................................................................................................... 10
4.4 Testing ........................................................................................................................................ 11
4.5 Deployment ................................................................................................................................ 11
Chapter 5: Implementation ...................................................................................................................... 12
5.1 Development Tools .................................................................................................................... 12
5.2 Class Design ............................................................................................................................... 12
5.3 GUI Layout Design ................................................................................................................... 13
5.4 Game Flow ................................................................................................................................. 14
5.5 Game Logic Code Snippet ........................................................................................................ 15
5.6 Back to Start And Exit Features ............................................................................................. 15
Chapter 6: Testing and Result ................................................................................................................. 16
6.1 Testing Approach ...................................................................................................................... 16
6.2 Test Environment...................................................................................................................... 16
6.3 Test Cases .................................................................................................................................. 16
6.4 Results ........................................................................................................................................ 17
6.5 BugHandling.............................................................................................................................. 17
6.6 User Feedback ........................................................................................................................... 18
6.7 Conclusion of Testing ............................................................................................................... 18
Chapter 7: Conclusion and Future Work ............................................................................................... 19
7.1 Conclusion ................................................................................................................................. 19
7.2 Future work ............................................................................................................................... 19
7.3 Final Thought ........................................................................................................................... 20
Chapter 8: References .............................................................................................................................. 21
8.1 Books and Text Materials......................................................................................................... 21
8.2 Online Resources ....................................................................................................................... 21
8.3 Tools and Software ................................................................................................................... 21

©Z. H. Sikder University of Science and Technology


P a g e | IX

List of Figures and Tables

Fig. 3-0-1: System Overview of the Rock Paper Scissors Game .................................................................... 5
Fig. 3-0-2: Use Case Diagram of the Rock Paper Scissors Game System ...................................................... 7
Fig. 3-0-3: Data Flow Diagram of the Rock Paper Scissors Game System..................................................... 8
Fig. 5-0-1: Development Tools .................................................................................................................... 12
Fig. 5-0-2: User Interface ............................................................................................................................ 13
Fig. 5-0-3: Left Side User Win Rite Side Computer Win .............................................................................. 14
Fig. 5-0-4: Game Logic Code ....................................................................................................................... 15
Fig. 6-0-1: Test Environment ....................................................................................................................... 16
Fig. 6-2: Test Case ....................................................................................................................................... 16
Fig. 6-0-3: Left Side Fig Win And Rite Side Fig Update Score ...................................................................... 17

©Z. H. Sikder University of Science and Technology


Page |1

Chapter 1: Introduction

1.1 Background of the Study


Games have long been used not only for entertainment but also for
learning and improving cognitive skills. With the advancement of
technology, even simple games like Rock, Paper, Scissors can be
developed using programming languages such as Java. Creating such a
game provides hands-on experience in object-oriented programming, GUI
design, and event-driven logic.
1.2 Problem Statement
Many beginner programmers face difficulty in understanding how
graphical interfaces and user input work together in software applications.
A small game project like Rock, Paper, Scissors can effectively help
students overcome this problem and develop better understanding of GUI
programming and logic flow.
1.3 Objectives of the Study
 To develop a simple Rock, Paper, Scissors game using Java.
 To implement a graphical user interface using Java Swing.
 To understand event-driven programming concepts.
 To enhance knowledge of object-oriented programming.
1.4 Scope of the Project
The project covers the implementation of a GUI-based Rock, Paper,
Scissors game. It allows a single player to play against the computer. The
system displays choices, evaluates results, and maintains basic
interaction. However, it does not include multiplayer mode or artificial
intelligence.

©Z. H. Sikder University of Science and Technology


Page |2

1.5 Significance of the Study


This project serves as a practical example for students learning Java
programming, particularly GUI development and logic implementation.
It provides a foundation for more complex application development and
enhances problem-solving ability.
1.6 Methodology
The game was developed using Java programming language with
Swing library for GUI. The system follows an event-driven model, where
user inputs trigger corresponding actions. Random number generation is
used for computer choices.
1.7 Features of the Project
 Simple and user-friendly interface.
 Implements random number generation for computer moves.
 Interactive GUI using Java Swing.
 Displays game results in real-time.
 Enhances logical thinking for beginners.
1.8 Social Impact
The Rock, Paper, Scissors game, though simple, has positive social
implications. It enhances logical thinking and decision-making, making it
useful not just as entertainment but also as a basic educational tool. This
project can help beginners in programming to understand randomization,
control structures, and GUI programming in Java.

©Z. H. Sikder University of Science and Technology


Page |3

Chapter 2: Literature Review

2.1 Introduction to Literature Review


In this section, we will briefly discuss the previous research and
studies related to the Rock-Paper-Scissors game. This will help us
understand various aspects such as strategic analysis, implementation, and
technological advancements in the game. Additionally, we will identify
the limitations in earlier studies, which will highlight the significance and
necessity of the current project.

2.2 Previous Studies


SNumerous studies have delved into the dynamics of the Rock-
Paper-Scissors (RPS) game, examining various aspects such as player
strategies, game theory applications, and human behavior patterns. One
significant contribution is by Zhang et al. (2020), who explored the
dynamics of players' strategies in repeated RPS games. Their research
revealed that human players often deviate from the Nash equilibrium,
exhibiting diverse and sometimes unpredictable behaviors.
Additionally, research by Wang et al. (2014) identified social cycling and
conditional responses in RPS games, highlighting the complexity of
human decision-making in competitive scenarios.
These studies underscore the intricate nature of decision-making in RPS
games, emphasizing the need for further exploration into the factors
influencing player choices and strategies.
2.3 Theoretical Framework
The theoretical foundation of this project is primarily based on the
principles of Game Theory, particularly focusing on the Nash
Equilibrium. Game Theory is a mathematical framework used for
analyzing strategic interactions where the outcome for each participant
depends on the actions of all involved. In the context of the Rock-Paper-

©Z. H. Sikder University of Science and Technology


Page |4

Scissors game, the Nash Equilibrium occurs when each player chooses
their strategy randomly, making the game fair and unpredictable.

Additionally, the project incorporates concepts from Machine Learning,


specifically Reinforcement Learning. This approach allows the system
to learn optimal strategies through trial and error, improving its
performance over time. By integrating these theoretical concepts, the
project aims to develop a system that can predict and counteract
opponents' moves effectively.

2.4 Comparison of Existing Methods / Technologies


In this section, various existing methods, techniques, or
technologies relevant to the research topic are compared. The strengths
and weaknesses of each approach are discussed to understand their
effectiveness and limitations. This comparison helps to identify the most
suitable method for the current study and highlights areas for
improvement.
2.5 Research Gaps and Limitations
This section identifies the gaps in the existing literature that the
current research aims to fill. It also discusses the limitations of previous
studies, such as sample size, methodology, or scope. Recognizing these
gaps justifies the need for the present study and defines its focus.

©Z. H. Sikder University of Science and Technology


Page |5

Chapter 3: System Analysis


3.1 Introduction
System analysis is the process of understanding the proposed game
system, identifying the input/output requirements, user interactions, and
internal logic. The goal is to ensure that the Rock Paper Scissors game
behaves correctly and provides a smooth user experience.
3.2 System Overview
The Rock Paper Scissors game is a simple, two-player game (User
vs Computer), where each player selects one of the three possible moves
— Rock, Paper, or Scissors. The system then determines the winner based
on predefined rules.

Fig. 3-0-1: System Overview of the Rock Paper Scissors Game

©Z. H. Sikder University of Science and Technology


Page |6

3.3 Functional Requirements


 Accept player input (Rock / Paper / Scissors)
 Randomly generate computer's move
 Compare both choices and determine the winner
 Display the result
 Option to play again
3.4 Non-Functional Requirements
 User-friendly interface
 Fast response (within 1 second)
 Cross-platform support (e.g., runs on any OS)
 Visually engaging (colors, feedback)

©Z. H. Sikder University of Science and Technology


Page |7

3.5 Use Case Diagram

Fig. 3-0-2: Use Case Diagram of the Rock Paper Scissors Game System

Use Case Description


 Actor: Player
 System: Accept input, generate random move, compare, show result

3.6 Data Flow Diagram (DFD)


If we go deeper, Level 1 DFD includes:

©Z. H. Sikder University of Science and Technology


Page |8

 Input Module
 Random Generator
 Decision Logic Module
 Output Module

Fig. 3-0-3: Data Flow Diagram of the Rock Paper Scissors Game System

©Z. H. Sikder University of Science and Technology


Page |9

Chapter 4: Methodology
This project follows the Waterfall Model of software development,
proceeding through well-defined sequential phases: Requirement
Analysis, Design, Implementation, Testing, and Deployment. The entire
methodology is described below.
4.1 Requirement Analysis
In the initial phase, the core functionalities of the Rock, Paper, Scissors
game were identified:

 The user must be able to choose Rock, Paper, or Scissors via a


graphical user interface.
 The computer will randomly select its move.
 The winner will be determined based on traditional game rules.
 Scores will be displayed and updated for both the user and the
computer.
 The interface should include a start screen, gameplay screen, and an
option to exit or go back.

All requirements were documented for further design and development.

©Z. H. Sikder University of Science and Technology


P a g e | 10

4.2 System Design


The system was designed using Java Swing for GUI development. The
design is component-based and consists of the following elements:

 Start Panel: A welcoming screen with a “Start Game” button.


 Game Panel: Displays buttons for Rock, Paper, Scissors; score
labels; result panel; and images for user and computer choices.
 Exit/Back Button Panel: Enables exiting the game or returning to
the start screen.
 Label Components: Used for dynamic display of user choice,
computer choice, result message, and score updates.
 Image Components: Associated icons for Rock, Paper, Scissors,
win, lose, and tie states.

Layout Managers like BorderLayout, GridLayout, and FlowLayout were


used to organize the UI elements efficiently.

4.3 Implementation
The application was implemented using Java and the Swing framework.
The main implementation details include:

Java Class: A single class Demo extends JFrame and implements


ActionListener.

Choice Handling: The user input is captured via buttons and compared
against the randomly generated computer choice.

 Logic: Standard game rules are used to determine the outcome.


 Score Tracking: Two integer variables (userWins, computerWins)
maintain the ongoing scores.
 Dynamic GUI Update: Based on user interaction, the labels and
image icons are updated in real-time.
 Reusable Method: The clearGameState() method resets the game
state when switching panels.

©Z. H. Sikder University of Science and Technology


P a g e | 11

4.4 Testing
Multiple test cases were executed to validate the correctness and stability
of the game:

 Functional Testing: Verified proper result display after each


choice.
 Boundary Testing: Checked behavior at 0 wins, multiple wins, and
continuous back/start switches.
 UI Testing: Ensured buttons respond as expected and image labels
update correctly.
 Exception Handling: Ensured application does not crash if an
image is missing or any component is null.

4.5 Deployment
The game can be run on any system with Java installed. It is a standalone
desktop application and does not require any external dependencies
beyond image assets.

Steps for deployment:

1. Place all image files (rock.png, paper.png, scissors.png, win.png,


lose.png, tie.png) inside a folder named images.
2. Compile the Java file.
3. Run the application using the java command or any IDE.

©Z. H. Sikder University of Science and Technology


P a g e | 12

Chapter 5: Implementation
This chapter describes how the “Rock Paper Scissors” game was
implemented. The game is built using the Java programming language and
the Swing GUI framework. It is a popular hand game where a player
competes against the computer by choosing between rock, paper, or
scissors.

5.1 Development Tools


The following tools and technologies were used in developing the
game:

Fig. 5-0-1: Development Tools

5.2 Class Design


The project uses two main classes:

 MainGame: Handles the GUI and user interaction.


 GameLogic: Contains the logic to determine the winner and return
results.

©Z. H. Sikder University of Science and Technology


P a g e | 13

5.3 GUI Layout Design


The GUI is divided into three sections:
1. Player Input Panel – Contains buttons for Rock, Paper, and
Scissors.
2. Result Panel – Displays who won the round.
3. Score Panel – Shows the score of the player and the computer.

Fig. 5-0-2: User Interface

©Z. H. Sikder University of Science and Technology


P a g e | 14

5.4 Game Flow


The following steps describe how the game works:

1. The player clicks on one of the buttons: Rock, Paper, or Scissors.


2. The computer randomly selects one of the three options.
3. The game logic compares both choices and determines the winner.
4. The result and the updated score are displayed on the GUI.

Fig. 5-0-3: Left Side User Win Rite Side Computer Win

©Z. H. Sikder University of Science and Technology


P a g e | 15

5.5 Game Logic Code Snippet

Fig. 5-0-4: Game Logic Code

5.6 Back to Start And Exit Features


 Back to Start Button: Clears the selected options and resets the
score.
 Exit Button: Closes the game widow and exits the program.

©Z. H. Sikder University of Science and Technology


P a g e | 16

Chapter 6: Testing and Result


6.1 Testing Approach
The testing approach for this project is based on manual testing. The
entire application was executed multiple times to validate the
functionality of each feature. Different combinations of user inputs and
computer choices were tested to check if the game behaves as expected.
6.2 Test Environment

Fig. 6-0-1: Test Environment

6.3 Test Cases

Fig. 6-2: Test Case

©Z. H. Sikder University of Science and Technology


P a g e | 17

6.4 Results
The results of testing show that the game is functioning as intended:

 All outcome scenarios (win, lose, draw) are handled correctly.


 The user interface responds without lag.
 Scoreboard updates are instant and accurate.
 Reset and exit buttons work perfectly.

Fig. 6-0-3: Left Side Fig Win And Rite Side Fig Update Score

6.5 BugHandling
During testing, a few minor bugs were detected and resolved:

 Bug: Score not resetting after clicking the Reset button.


Fix: Added playerScore = 0; computerScore = 0; inside the reset
method.
 Bug: Computer sometimes showing null as a choice.
Fix: Ensured Math.random() is bounded within 3 and mapped to
correct choices.

©Z. H. Sikder University of Science and Technology


P a g e | 18

6.6 User Feedback


Feedback was collected from a few users after using the game. The
comments were generally positive, with users appreciating the simplicity
and fun aspect of the game. A few suggested adding sound effects or
animations in future versions.
6.7 Conclusion of Testing
Based on the manual testing results and user feedback, the “Rock
Paper Scissors” game has proven to be stable, accurate, and user-friendly.

©Z. H. Sikder University of Science and Technology


P a g e | 19

Chapter 7: Conclusion and Future Work


7.1 Conclusion
In this project, we have successfully developed a simple yet
effective Rock Paper Scissors game using Java GUI (Swing). The game
is user-friendly, responsive, and provides an engaging gaming experience.
It is designed in such a way that the player can choose between Rock,
Paper, or Scissors and play against the computer. The score and result are
displayed in real-time.

Through this project, we have gained experience in:

 Designing Graphical User Interfaces using Java Swing.


 Handling user events such as button clicks.
 Implementing game logic and controlling program flow using
conditions.
 Updating GUI components dynamically based on user interactions.

This project has significantly helped us improve our programming skills


and has boosted our confidence in developing real-world applications.

7.2 Future work


Although the game has been developed successfully, there are several
features that can be added in the future to make it more interactive and
advanced. Some future improvements are as follows:

1. Multiplayer Mode: Allowing two users to play the game either on


the same computer or over a network.
2. Sound Effects and Animation: Adding sound effects and simple
animations for each move and result to enhance user experience.
3. Difficulty Levels: Introducing AI-based difficulty levels like
Beginner, Intermediate, and Expert.
4. Game History Storage: Saving match history to a file so players
can analyze past games.

©Z. H. Sikder University of Science and Technology


P a g e | 20

5. Mobile Version Development: Creating Android or iOS versions


of the game for mobile users.

7.3 Final Thought


This project has served as an important step in our software
development journey. It helped us not only in learning a programming
language but also in understanding the process of solving real-life
problems and designing software from a user’s perspective. In the future,
this experience will help us take on larger and more complex software
projects with confidence.

©Z. H. Sikder University of Science and Technology


P a g e | 21

Chapter 8: References
This chapter lists all the references and sources that were consulted
during the development of the project. These resources provided valuable
guidance and information in understanding programming concepts,
designing the user interface, implementing logic, and completing the
project successfully.
8.1 Books and Text Materials
 Herbert Schildt, Java: The Complete Reference, 11th Edition,
McGraw-Hill Education.
 Kathy Sierra & Bert Bates, Head First Java, 2nd Edition, O'Reilly
Media.
 Deitel & Deitel, Java: How to Program, 10th Edition, Pearson
Education.

8.2 Online Resources


 Oracle Official Java Documentation
 GeeksforGeeks – Java Tutorials
 W3Schools – Java Programming
 Stack Overflow – For resolving development issues.
 TutorialsPoint – Java Swing

8.3 Tools and Software


 Java Development Kit (JDK) – Version 17
 IntelliJ IDEA / Eclipse IDE – For coding and compiling the
application
 Windows OS – Operating system for development and testing
 Swing Framework – For building the GUI

©Z. H. Sikder University of Science and Technology

You might also like