AJP Microproject

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 39

Loknete Ma.

Hanmantrao Patil Charitable Trust’s


ADARSH INSTITUTE OF TECHNOLOGY AND
RESEARCH CENTRE ,VITA
MSBTE- 0991

FIFTH SEMESTER
(Year: 2024-25)
Micro Project
Advanced Java Programming

Title of the Project: Chess Board Game Using Swing Framework.

Branch: Computer Technology (CM5I)

Submitted By:

Sr. No Name Roll No.

1. Omkar Rameshkumar Kadam 3123

1
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION, MUMBAI

MICRO PROJECT
Progress Report / Weekly Report

Title of the Project: Chess Board Game Using Swing Framework.


Course: AJP (22517) Program : Computer Technology (CM5I)

Sign of
Week Duration
Date Work / Activity Performed the
No in Hrs.
Faculty
1

10

11

12

13

14

15

2
Teacher Evaluation Sheet for Micro Project

Course Title and Code: -Advanced Java Programming (22517)

Title of the Project: - Chess Board Game Using Swing Framework.

COs addressed by the Micro Project:

CO a: Develop programs using GUI Framework (AWT and Swing).

CO b: Handle events of AWT and Swing components

CO c: Develop programs to handle events in Java Programming

CO d: -

CO e: -

CO f: -

Marks:-

Marks Marks obtained


for by the Total
Roll No. Name Of Student Group individual Marks
Work based on viva (10)
(06) (04)
3123 Omkar Rameshkumar Kadam

Name and designation of Faculty Member: Ms. D. D. Suryawanshi


Lecturer (Computer Technology Department)

Signature: _______________________

3
Loknete Ma. Hanmantrao Patil Charitable Trust’s
Adarsh Institute of Technology & Research Centre Vita,

CERTIFICATE
This is to certify that the micro project report entitled

“Chess Board Game Using Swing Framework.”


Submitted by

Sr. No. Name of Student Roll No.


01 Omkar Rameshkumar Kadam 3123

For Fifth Semester of Diploma in Computer Technology of course Advanced Java Programming

(22517) for academic year 2024-25 as per MSBTE, Mumbai curriculum of ‘I’ scheme.

DIPLOMA OF ENGINEERING
(Computer Technology)

SUBMITTED TO
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION MUMBAI
ACADEMIC YEAR 2024-25

Project Guide H.O.D Principal


Ms. D. D. Suryawanshi Mr.A.A.Vankudre Dr.P.S.Patil

4
ACKNOWLEDGEMENT

I express my sincere gratitude Ms. D. D. Suryawanshi Department of Computer


Technology, for his/her stimulating guidance, continuous encouragement and supervision
throughout the course of present work.

I would like to place on record my deep sense of gratitude to Prof. A. A. Vankudre


HOD-Department of Computer Technology, for his generous guidance, help and useful
suggestions.

I am extremely thankful to Principal Dr. P. S. Patil for this motivation and providing me
infrastructural facilities to work in, without which this work would not have been possible.

I would like to express my gratitude to all my colleagues for their support, co-operation
and fruitful discussions on diverse seminar topics and technical help.

Name of Student Sign

1. Omkar Rameshkumar Kadam

5
Index
Sr. No. Content Page No.

1.0 Rationale 9

2.0 Course Outcomes Addressed 9

3.0 Literature Review 9

4.0 Actual Methodology Followed 9

5.0 Actual Resources Used 10

6.0 Outputs of the Micro Project 10-13

7.0 Skill Developed / learning out of this Micro Project 14

8.0 Applications of this Micro Project 14

9.0 Area of Future Improvement 14

6
PART A - Micro-Project Proposal

Title of Micro-Project: Chess Board Game Using Swing Framework.


1.0 Brief Introduction:
The Chess Board Game project is a graphical user interface (GUI) application developed in
Java using the javax.swing package. It simulates a chess game by visually representing a
chessboard and pieces, allowing users to interact with the board through mouse clicks. The
project showcases basic GUI design, game piece movement, and event handling in Java
Swing.

2.0 Aim of the Micro-Project


The aim of this project is to develop a functional chessboard game where users can visually
interact with chess pieces. It serves as a demonstration of handling user input, rendering
graphical elements, and simulating simple game mechanics in a Java-based GUI environment.

3.0 Intended Course Outcomes


a) Develop programs using GUI Framework (AWT and Swing).
b) Handle events of AWT and Swing components
c) Develop programs to handle events in Java Programming

4.0 Literature Review


 Java Swing Framework: Java Swing is a widely used toolkit for building graphical user
interfaces in Java. It provides components like panels, labels, and buttons, allowing developers
to build applications like this chess game.

 Event Handling in Java: Handling user input in GUI applications, particularly with mouse
and keyboard actions, is critical in game development. The project uses MouseAdapter to
manage clicks on the board, demonstrating event-driven programming.

5.0 A Quiz Management


System In Java is to
perform the examination
for the student where an
teacher can add questions,

7
6.0 set password for quiz ,set
timer for the exam and
types of examination
depends on the category.
As a user student can
attend
7.0 those exams. The student
user can submit the test
after finish the exam and
get results through mail on
there email id(it is
8.0 implemented by mail
services in java). A teacher
and admin user can get
the history of his exam
results. Admin also can
9.0 check the complete
activity of all the users and
8
teacher users. Like exams
and results.
10.0 A Quiz Management
System In Java is to
perform the examination
for the student where an
teacher can add questions,
11.0 set password for quiz ,set
timer for the exam and
types of examination
depends on the category.
As a user student can
attend
12.0 those exams. The student
user can submit the test
after finish the exam and
get results through mail on
there email id(it is
9
13.0 implemented by mail
services in java). A teacher
and admin user can get
the history of his exam
results. Admin also can
14.0 check the complete
activity of all the users and
teacher users. Like exams
and results.
15.0 A Quiz Management
System In Java is to
perform the examination
for the student where an
teacher can add questions,
16.0 set password for quiz ,set
timer for the exam and
types of examination
depends on the category.
10
As a user student can
attend
17.0those exams. The student
user can submit the test
after finish the exam and
get results through mail on
there email id(it is
18.0implemented by mail
services in java). A teacher
and admin user can get
the history of his exam
results. Admin also can
19.0check the complete
activity of all the users and
teacher users. Like exams
and results.
20.0A Quiz Management
System In Java is to
11
perform the examination
for the student where an
teacher can add questions,
21.0 set password for quiz ,set
timer for the exam and
types of examination
depends on the category.
As a user student can
attend
22.0 those exams. The student
user can submit the test
after finish the exam and
get results through mail on
there email id(it is
23.0 implemented by mail
services in java). A teacher
and admin user can get

12
the history of his exam
results. Admin also can
24.0 check the complete
activity of all the users and
teacher users. Like exams
and results.
25.0 Quiz Management System
In Java is to perform the
examination for the
student where an teacher
can add questions,
26.0 set password for quiz ,set
timer for the exam and
types of examination
depends on the category.
As a user student can
attend

13
27.0those exams. The student
user can submit the test
after finish the exam and
get results through mail on
there email id(it is
28.0implemented by mail
services in java). A teacher
and admin user can get
the history of his exam
results. Admin also can
29.0check the complete
activity of all the users and
teacher users. Like exams
and results
30.0Quiz Management System
In Java is to perform the
examination for the

14
student where an teacher
can add questions,
31.0 set password for quiz ,set
timer for the exam and
types of examination
depends on the category.
As a user student can
attend
32.0 those exams. The student
user can submit the test
after finish the exam and
get results through mail on
there email id(it is
33.0 implemented by mail
services in java). A teacher
and admin user can get
the history of his exam
results. Admin also can
15
34.0 check the complete
activity of all the users and
teacher users. Like exams
and results
35.0 Quiz Management System
In Java is to perform the
examination for the
student where an teacher
can add questions,
36.0 set password for quiz ,set
timer for the exam and
types of examination
depends on the category.
As a user student can
attend
37.0 those exams. The student
user can submit the test
after finish the exam and
16
get results through mail on
there email id(it is
38.0 implemented by mail
services in java). A teacher
and admin user can get
the history of his exam
results. Admin also can
39.0 check the complete
activity of all the users and
teacher users. Like exams
and results
40.0 A Quiz Management
System In Java is to
perform the examination
for the student where an
teacher can add questions,
41.0 set password for quiz ,set
timer for the exam and
17
types of examination
depends on the category.
As a user student can
attend
42.0those exams. The student
user can submit the test
after finish the exam and
get results through mail on
there email id(it is
43.0implemented by mail
services in java). A teacher
and admin user can get
the history of his exam
results. Admin also can
44.0check the complete
activity of all the users and
teacher users. Like exams
and result
18
45.0 A Quiz Management
System In Java is to
perform the examination
for the student where an
teacher can add questions,
46.0 set password for quiz ,set
timer for the exam and
types of examination
depends on the category.
As a user student can
attend
47.0 those exams. The student
user can submit the test
after finish the exam and
get results through mail on
there email id(it is
48.0 implemented by mail
services in java). A teacher
19
and admin user can get
the history of his exam
results. Admin also can
49.0 check the complete
activity of all the users and
teacher users. Like exams
and result
50.0 A Quiz Management
System In Java is to
perform the examination
for the student where an
teacher can add questions,
51.0 set password for quiz ,set
timer for the exam and
types of examination
depends on the category.
As a user student can
attend
20
52.0those exams. The student
user can submit the test
after finish the exam and
get results through mail on
there email id(it is
53.0implemented by mail
services in java). A teacher
and admin user can get
the history of his exam
results. Admin also can
54.0check the complete
activity of all the users and
teacher users. Like exams
and result
55.0 Aim of the Micro-Pro

  Student records
are often viewed as
paperwork produced for
the education
21
 bureaucracy.
  However, a well-
designed student
record system, whether
using paper documents
or
 automated systems,
yields many benefits.
  The most
important of these is
the ability to report
information for decision
making
 about individual
students, schools,

22
programs, and school
districts.
  A second benefit,
particularly with
automated systems, is
efficiency in processing
and
 exchanging student
records among schools.
  Student records
are often viewed as
paperwork produced for
the education
 bureaucracy.
  However, a well-
designed student
23
record system, whether
using paper documents
or
 automated systems,
yields many benefits.
  The most
important of these is
the ability to report
information for decision
making
 about individual
students, schools,
programs, and school
districts.
  A second benefit,
particularly with
24
automated systems, is
efficiency in processing
and
 exchanging student
records among such
5.0 Proposed Methodology

1) Knowing the basics of the topic.

2) Decide aim of the project and collect the data.

3) Prepare project proposal.

4) Search Literature reviews.

5) Analysis of data.

6) Discussion over preparing and correction in booklet and report.

7) Converting the content of project in report writing.

8) Checking and correction in report writing.

9) Rechecking and finalizing report writing.

10) Final submission and oral presentation of micro project.

6.0 Resources Required

Sr.
Name of Resource/ Material Specifications Quantity Remark
No.

1 Computer System i-5 1

2 Microsoft Word 2010 1

25
3 Internet Any 1

7.0 Action Plan

Planned Name of
Sr. Planned
Details of activity Finish Responsible Team
No. start date
date Members

1 Project Proposal
2 Data Collection & Analysis

3 Preparation of Prototype/ Model

4 Preparation of Report

5 Presentation & Submission

PART B - Micro- Project Proposal

Title of Micro-Project: Chess Board Game Using Swing Framework.


1.0 Rationale:
The Chess Board Game project demonstrates the implementation of basic game mechanics,
graphics rendering, and event-driven user interactions within a simple, accessible framework.
It provides a practical example of Java GUI programming and is aimed at helping learners
understand how to build an interactive board game with minimal resources.

2.0 Course Outcomes Addressed


a) Develop programs using GUI Framework (AWT and Swing).
b) Handle events of AWT and Swing components
c) Develop programs to handle events in Java Programming

3.0 Literature Review

26
 Game Design: Many board games, including chess, require an efficient way to represent
the state of the game (e.g., the position of pieces). This project uses arrays to store and
update piece positions, reflecting changes visually.
 Artificial Intelligence in Chess: Modern chess applications often incorporate AI to play
against the user. While this project focuses on the GUI aspect, many chess games
eventually integrate AI to enhance gameplay.

4.0 Actual Methodology Followed:

Member 1): Name: Omkar Rameshkumar Kadam


Work: Finalize the group & project

Member 2): Name: Omkar Rameshkumar Kadam

Work: Search information regarding project subject.

Member 3): Name: Omkar Rameshkumar Kadam

Work: Collect information and discuss with group members about proposal.

Prepare proposal and submit to the guide.

Member 4): Name: Omkar Rameshkumar Kadam

Work: Analyze and finalize the information of the project report.

Member 5): Name: Omkar Rameshkumar Kadam

Work: Write project report

Member 6): Name : Omkar Rameshkumar Kadam

Work: Prepare rough sketch and final chart


5.0 Actual Resources Used

Sr.
Name of Resource/ Material Specifications Quantity Remark
No.

1 Computer System i-5 1

2 Microsoft Word 2010 1

3 Internet Any 1

6.0 Source Code

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
27
public class ChessBoardGame extends JFrame {
private static final int BOARD_SIZE = 8;
private JPanel[][] squares = new JPanel[BOARD_SIZE][BOARD_SIZE];
private JLabel[][] pieces = new JLabel[BOARD_SIZE][BOARD_SIZE];
private Point selectedSquare = null;

public ChessBoardGame() {
setTitle("Chess Board Game");
setSize(600, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(BOARD_SIZE, BOARD_SIZE));

initializeBoard();
initializePieces();
}

private void initializeBoard() {


boolean isWhite = false;
for (int row = 0; row < BOARD_SIZE; row++) {
for (int col = 0; col < BOARD_SIZE; col++) {
JPanel square = new JPanel();
square.setBackground(isWhite ? Color.WHITE : Color.GRAY);
square.addMouseListener(new SquareClickListener(row, col));
squares[row][col] = square;
add(square);
isWhite = !isWhite;
}
isWhite = !isWhite;
}
}

private void initializePieces() {


String[][] initialBoard = {
{"R", "N", "B", "Q", "K", "B", "N", "R"},
{"P", "P", "P", "P", "P", "P", "P", "P"},
{null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null},
{"P", "P", "P", "P", "P", "P", "P", "P"},
{"R", "N", "B", "Q", "K", "B", "N", "R"},
};

for (int row = 0; row < BOARD_SIZE; row++) {


for (int col = 0; col < BOARD_SIZE; col++) {

28
if (initialBoard[row][col] != null) {
String piece = initialBoard[row][col];
pieces[row][col] = new JLabel(getPieceUnicode(piece, row));
pieces[row][col].setFont(new Font("Arial", Font.PLAIN, 40));
pieces[row][col].setHorizontalAlignment(SwingConstants.CENTER);
squares[row][col].add(pieces[row][col]);
}
}
}
}

private String getPieceUnicode(String piece, int row) {


switch (piece) {
case "R":
return row == 0 ? "\u2656" : "\u265C"; // White or Black Rook
case "N":
return row == 0 ? "\u2658" : "\u265E"; // White or Black Knight
case "B":
return row == 0 ? "\u2657" : "\u265D"; // White or Black Bishop
case "Q":
return row == 0 ? "\u2655" : "\u265B"; // White or Black Queen
case "K":
return row == 0 ? "\u2654" : "\u265A"; // White or Black King
case "P":
return row == 1 ? "\u2659" : "\u265F"; // White or Black Pawn
default:
return "";
}
}

// Handle clicks on the board


private class SquareClickListener extends MouseAdapter {
private int row, col;

public SquareClickListener(int row, int col) {


this.row = row;
this.col = col;
}

@Override
public void mousePressed(MouseEvent e) {
if (selectedSquare == null) {
// Select the piece if there is one
if (pieces[row][col] != null) {
selectedSquare = new Point(row, col);

29
squares[row][col].setBackground(Color.YELLOW); // Highlight selected square
}
} else {
// Move the piece to the new square
Point destination = new Point(row, col);
movePiece(selectedSquare, destination);
selectedSquare = null; // Deselect after move
}
}
}

// Move the piece from one square to another


private void movePiece(Point from, Point to) {
JLabel piece = pieces[from.x][from.y];
pieces[from.x][from.y] = null;
squares[from.x][from.y].removeAll(); // Remove piece from old square

pieces[to.x][to.y] = piece;
squares[to.x][to.y].add(piece); // Place piece on new square

// Reset background color of the old and new squares


squares[from.x][from.y].setBackground((from.x + from.y) % 2 == 0 ? Color.WHITE :
Color.GRAY);
squares[to.x][to.y].setBackground((to.x + to.y) % 2 == 0 ? Color.WHITE : Color.GRAY);

revalidate();
repaint();
}

public static void main(String[] args) {


SwingUtilities.invokeLater(() -> {
ChessBoardGame game = new ChessBoardGame();
game.setVisible(true);
});
}}

import
java.awt.event.ActionEvent;

30
import
java.awt.event.ActionListen
er;
import
javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import
javax.swing.JOptionPane;
import
javax.swing.JRadioButton;
class OnlineTest extends
JFrame implements
ActionListener {
private static final long
serialVersionUID = 1L;
31
JLabel label;
JRadioButton radioButton[]
= new JRadioButton[5];
JButton btnNext,
btnBookmark;
import
java.awt.event.ActionEvent;
import
java.awt.event.ActionListen
er;
import
javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import
javax.swing.JOptionPane;

32
import
javax.swing.JRadioButton;
class OnlineTest extends
JFrame implements
ActionListener {
private static final long
serialVersionUID = 1L;
JLabel label;
JRadioButton radioButton[]
= new JRadioButton[5];
JButton btnNext,
btnBookmark;
import
java.awt.event.ActionEvent;
import
java.awt.event.ActionListen
er;
33
import
javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import
javax.swing.JOptionPane;
import
javax.swing.JRadioButton;
class OnlineTest extends
JFrame implements
ActionListener {
private static final long
serialVersionUID = 1L;
JLabel label;
JRadioButton radioButton[]
= new JRadioButton[5];
34
JButton btnNext,
btnBookmark;
import
java.awt.event.ActionEvent;
import
java.awt.event.ActionListen
er;
import
javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import
javax.swing.JOptionPane;
import
javax.swing.JRadioButton;

35
class OnlineTest extends
JFrame implements
ActionListener {
private static final long
serialVersionUID = 1L;
JLabel label;
JRadioButton radioButton[]
= new JRadioButton[5];
JButton btnNext,
btnBookmark;
import
java.awt.event.ActionEvent;
import
java.awt.event.ActionListen
er;
import
javax.swing.ButtonGroup;
36
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import
javax.swing.JOptionPane;
import
javax.swing.JRadioButton;
class OnlineTest extends
JFrame implements
ActionListener {
private static final long
serialVersionUID = 1L;
JLabel label;
JRadioButton radioButton[]
= new JRadioButton[5];
JButton btnNext,
btnBookmark;
Output:

37
Image-1

Image- 2

7.0 Skill Developed / learning out of this Micro Project


 Java GUI Programming: Understanding how to build interactive graphical applications
using the Swing framework.

 Event Handling: Managing user interactions via mouse events, such as selecting and
moving pieces on the board.

 Game Logic: Implementing basic game mechanics, such as board layout, piece
positioning, and movement.

38
 Problem-Solving: Learning to manage data structures for game states and design
solutions for visual representation and user interaction.

8.0 Applications of this Micro Project


This project can be used as a learning tool for beginner programmers to practice Java GUI
development. It can also serve as a foundation for more complex chess games, including
multiplayer versions, AI integration, or online play. Additionally, it demonstrates how to build
structured applications with a graphical interface, a valuable skill for many types of software
development.

9.0 Area of Future Improvement

 AI Opponent: Add an AI component to play against the user.


 Multiplayer Functionality: Enable network-based or local multiplayer mode.
 Chess Rules Implementation: Incorporate full chess rules, such as castling, en passant,
and checkmate detection.

 Enhanced UI Design: Improve the visual aesthetics of the board and pieces, possibly
with custom graphics or animations.
*********

39

You might also like