Sie sind auf Seite 1von 25

Computer TriViva

“COMPUTER TRIVIVA”
A PROJECT REPORT

Submitted by
AMOL SALUNKHE
INDRAKUMAR VANJARE

Under the Guidance of


Prof. Rane V. N.
Computer Engg. Dept.

In a partial fulfilment for the award of the degree of


BACHELOR OF ENGINEERING
IN
COMPUTER ENGINEERING

DEPARTMENT OF COMPUTER ENGINEERING

GHARDA INSTITUTE OF TECHNOLOGY

APR 2018

Mumbai University
CERTIFICATE

This is to certify that the project work entitled COMPUTER TRIVIVA is the
original work of AMOL SALUNKHE, INDRAKUMAR VANJARE of
TE Computer Engineering Who carried out the project work under my
supervision. The work is satisfactory for the Term Work Of Subject
Networking Programming Laboratory in Degree Computer Engineering of
University of Mumbai.

Date : Prof. Rane V. N.


Place : Lavel Department of Computer Engg.
ACKNOWLEDGMENT

We are presenting this project report on “COMPUTER TRIVIVA” as part of the


curriculum Term Work Of Network Programming Laboratory In Third Year Computer
Engineering of University of Mumbai with immense pleasure. We started working on it with
a zeal and enthusiasm but then quickly realized that for satisfactorily completing the project
not only require conviction and perseverance, but without due help and guidance such a task
becomes futile. We wish to thank all the people who gave me an unending support right from
the stage the idea was conceived. It gives us great pleasure, on the completion of this project,
to acknowledge and appreciate all those who were there to help us.
We express our sincere and profound thanks to all our teachers. We wish to thank
Prof. Rane V. N. (Subject Teacher) for his student-like enthusiasm and his guidance from
time to time. We heartily thank Prof. Dr. P. K. Roy (HOD) for all help and valuable time.
His valuable advice has helped me bring this work to completion. We take this opportunity to
express our sincere gratitude to the Principal Dr. P.S.Joshi (GIT, Lavel) for providing a good
environment and facilities to complete this project.
We would like to thank our college GIT (Lavel) for providing the resources for
project stage. And last but not least, all our friends, who have helped us directly or indirectly
throughout the project.
ABSTRACT

The sole intention behind the consideration of this Project is to give viva practice of
various subjects to Students in Quiz format.

This project is developed considering “QUIZ” information keeping context of the


various subjects & students in mind.

Here, data is stored in same java file and this database file is basically used as
MASTER file. Results are displayed after each question and also after student
completes its allocated questions.

Keywords : Viva, Student, Questions, Subjects, Quiz


TABLE OF CONTENTS

Sr No Contents Page No

1 Introduction 7

2 Overall Description 8

3 Hardware Software Requirements 9

4 Screenshots 10

5 Code 12

6 Conclusion 24

7 Future Scope, References 25


INTRODUCTION

This ‘COMPUTER TRIVIVA' Project is designed for a students in which you can
generate and manage a simple database for questions. The question number is
automatically generated by the software and is stored in a same client java file by the
name ' TriviaClient'. In this software some fixed number of questions will be asked to
the user with four options.

The client which displays the question, is connected to the server. It sends a request to
the server(the question), which in turns sends a response to client after verifying that
the answer was correct or incorrect. Multiple clients are also allowed !.

At the end of the trivia the student has the option to start a new viva . At the end of
trivia user will get the results. The student can exit the game at any time. It also has a
simple menu bar that allows the student to exit the game or as was mentioned before,
and also provides adequate help for new users of the trivia.
OVERALL DESCRIPTION
PURPOSE
We have developed Computer Trivia Quiz game to give student viva practice of various
engineering subjects questions in easy quick manner.

OBJECTIVES
 To make this application popular among students.
 Facilitates for viva & remove fear of actual viva exams from students

REFERENCES
Cricket Trivia Game 3.0

TECHNOLOGIES TO BE USED
Java Virtual Machine

TOOLS TO BE USED
Java 1.8

SYSTEM FUNCTIONS
The trivia is very simple to play. The question is displayed on the screen and the user is
required to answer the it by choosing either A,B,C,D. The player has to answer fixed number
of questions. The questions are based on various engineering subjects.

USER CHARACTERISTICS
The key feature of the elements of this system is:
1. Administrator- Can update questionnaires database.

2. Student- Can select the New Viva. Can answer the various questions.
HARDWARE & SOFTWARE REQUIREMENT

SOFTWARE INTERFACE

Front End Client - The applicant and interface is built using Java Client/ Server Format

System Requirements :

1. The Java Virtual Machine (JVM)

2. Command Prompt

HARDWARE INTERFACE

The Server Application can be run on any machine connected in LAN & installed with Java..
Multiple clients can connect to this machine through LAN running client program on it.
SCREENSHOTS

COMPILING SERVER

COMPILING CLIENT
STARTUP SCREEN QUESTION HOME

CORRECT/INCORRECT RESULT
CODE
TriviaMultiServer.java
import java.net.*;
import java.io.*;
public class TriviaMultiServer
{
public static void main(String[] args) throws IOException
{
ServerSocket serverSocket = null;
boolean listening = true;
try
{
serverSocket = new ServerSocket(4444);
}
catch (IOException e)
{
System.err.println("Could not listen on port: 4444.");
System.exit(-1);
}
while (listening)
new TriviaMultiServerThread(serverSocket.accept()).start();
serverSocket.close();
}

TriviaProtocol.java
//THE PROTOCOL USED BY THE SERVER TO CHECK QUESTIONS SENT BY
SERVER
import java.net.*;
import java.io.*;
public class TriviaProtocol
{
private String[] answers = {"B","A","C","A","C","A","C","C","B","D"};
private int state = 0, i = 0;
public String processInput(String theInput)
{
String theOutput = null;
if (state == 0 || theInput.equalsIgnoreCase("newGame"))
{
theOutput = "Press Next to Begin. Goodluck" ;
state = 1;
}
else if(i < 20)
{
if(theInput.equalsIgnoreCase("Exit"))
{
theOutput = "Bye";
}
else if (theInput.equalsIgnoreCase(answers[i]))
{
theOutput = "Correct";
i++;
}
else
{
theOutput = "INCORRECT !!!" ;
i++;
}
if(i == 20 ) i = 0;
}
return theOutput;
}
}

TriviaMultiServerThread.java
import java.net.*;
import java.io.*;
public class TriviaMultiServerThread extends Thread
{
private Socket socket = null;
public TriviaMultiServerThread(Socket socket)
{
super("TriviaMultiServerThread");
this.socket = socket;
}
public void run()
{
try
{
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
BufferedReader in = new BufferedReader(
new InputStreamReader(
socket.getInputStream()));
String inputLine, outputLine;
TriviaProtocol kkp = new TriviaProtocol();
outputLine = kkp.processInput(null);
out.println(outputLine);

while ((inputLine = in.readLine()) != null)


{
outputLine = kkp.processInput(inputLine);
out.println(outputLine);
if (outputLine.equals("Bye"))
break;
}
out.close();
in.close();
socket.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}

TriviaClient.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.net.*;

public class TriviaClient


{
static Socket kkSocket = null;
static String server =null;
public static int i = 0;
static int begin = 0;
static ButtonGroup group = new ButtonGroup();
static JTextArea quesArea = new JTextArea();
static JButton submitButton = new JButton();
static JButton nextButton = new JButton();
static JRadioButton aRadioButton = new JRadioButton();
static JRadioButton bRadioButton = new JRadioButton();
static JRadioButton dRadioButton = new JRadioButton();
static JRadioButton cRadioButton = new JRadioButton();
static JRadioButton invis = new JRadioButton();
static JFrame frame = new JFrame("Comp Engg. Sem 6 Viva");
static int correct = 0;
static boolean nGame = false;
static JMenuItem newGame = new JMenuItem("New Viva");

//THE QUESTIONS ASKED IN THE VIVA


static String[] questions =
{
"QUESTION 1\nWhich of the following is not a part of delivery management?
\n\n(A) Proposal\n(B) Analysis\n(C) Execution \n(D) Closure\n",
"QUESTION 2\nIdentifying business needs/concerns/high level requirements in the
mind of customers. This is done in which stage?\n\n(A) Elicitation\n(B) Analysis\n(C)
Documentation\n(D) Validation\n",
"QUESTION 3\nWhile developing a system for a client with rapidly changing
requirement which of the following is the appropriate software?\n\n(A) Waterfall\n(B)
Incremental \n(C) Iterative \n(D) Maintenance \n",
"QUESTION 4\nProject management involves balancing which of the following
factor?\n\n(A) All the Options\n(B) Quality\n(C) Resourse\n(D) Scope & Time\n",
"QUESTION 5\nHigh quality program necessary to follow?\n\n(A) Testing
methodology\n(B) Design method\n(C) S/W Developement Method\n(D) Coding
method\n",
"QUESTION 6\nWhich is quality assurance activity?\n\n(A) Process Audit\n(B)
Code Review\n(C) Coding\n(D) Testing\n",
"QUESTION 7\nWhat gets improved on good coding?\n\n(A) Readability and size
\n(B) Complexity and size\n(C) Readability and maintainability\n(D) Maintainability and
complexity\n",
"QUESTION 8\nName the stages that SDLC covers in s/w development?\n\n(A)
None\n(B) Requirements, design, testing, coding\n(C) Requirements, design, testing,
coding and maintenance\n(D) Design, testing, coding and maintenance\n",
"QUESTION 9\nProject quality goal are found in?\n\n(A) Proj estimates\n(B)
OLBM\n(C) Work Mgmt plan\n(D) Metric plan\n",
"QUESTION 10\nThe entire process of ensuring quality is known as ?\n\n(A)
Quality Audit\n(B) Quality Control\n(C) Quality Standard\n(D) Quality Management\n",

"QUESTION 1\nModulation is defined as.... ?\n\n(A) The distance between the


uplink and downlink frequencies\n(B) The process of changing the characteristics of a
carrier frequency\n(C) The separation between adjacent carrier frequencies\n(D) The
number of cycles per unit of time \n",
"QUESTION 2\nWhat is the air interface between the Mobile Station (MS) and Base
Transceiver Station (BTS) called?\n\n(A) Um \n(B) Tx\n(C) Rx\n(D) HLR\n",
"QUESTION 3\nWhat is the basic service unit of GSM communications? \n\n(A)
Location Area \n(B) OLMN Service Area\n(C) Cell\n(D) MSC / VLR Service Area\n",
"QUESTION 4\nThe Base Station Subsystem (BSS) comprises of what?\n\n(A) The
Base Transceiver Station and Base Station Controller\n(B) The Base System Transcontroller
and Base Station Condenser\n(C) The Base Transcript System and Base System Computer
\n(D) The Transfer Station and Base Station Computer n\n",
"QUESTION 5\nA GSM cell can cover a distance up to.... ?\n\n(A) 35Km\n(B)
15Km\n(C) 25Km \n(D) 10Km\n",
"QUESTION 6\nThe effective range of a GSM cell depends on what?\n\n(A) All of
the above\n(B) Frequency in use & Transmitter power \n(C) Required data rate of the
Mobile Station (MS) \n(D) Geographical conditions \n",
"QUESTION 7\nThe Base Station Controller (BSC) communicates with the Base
Transceiver Station (BTS) over what interface?\n\n(A) Hertz\n(B) Tx/Rx\n(C) Abis\n(D)
cbit\n",
"QUESTION 8\nMacro, Micro, Pico, Femto and Umbrella are all types of
what?\n\n(A) Uplink and downlink channels\n(B) GSM filters \n(C) Cell sizes in a GSM
network\n(D) GSM interfaces \n",
"QUESTION 9\nGPRS stands for....?\n\n(A) Global Prefence for Radio
Systems\n(B) General Packet Radio Service\n(C) Gateway for Packet Radio Services
\n(D) General Platform for Radio Systems \n",
"QUESTION 10\nHigh mobility users of 4th generation mobile telecommunications
(4G) networks should be able to achieve connection speeds of.... ?\n\n(A) 10 Gigawatts\n(B)
2 Gbit/s\n(C) 1 Gbit/s\n(D) 100 Mbit/s\n",
""
};

public static void main(String [] args) throws IOException


{
JPanel contentPane = new JPanel();
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenuFile = new JMenu();
JMenuItem jMenuFileExit = new JMenuItem();
JMenu jMenuHelp = new JMenu();
JMenuItem jMenuHelpAbout = new JMenuItem();
JPanel jPanel1 = new JPanel();
GridBagLayout gridBagLayout1 = new GridBagLayout();
JMenuItem helptopics = new JMenuItem("Help Topics");
JMenuItem readme = new JMenuItem("Read Me");
quesArea.setEditable(false);
contentPane = (JPanel) frame.getContentPane();
contentPane.setLayout(gridBagLayout1);
frame.setSize(new Dimension(300, 500));
frame.setResizable(false);
jMenuFile.setText("File");
jMenuFileExit.setText("Exit");
jMenuHelp.setText("Help");
jMenuHelp.add(helptopics);
jMenuHelp.add(readme);
jMenuFile.add(newGame);
quesArea.setText("\n\n\tWelcome To Computer Engg. 6 Sem Viva");
quesArea.setLineWrap(true);
quesArea.setWrapStyleWord(true);
submitButton.setLabel("Submit");
nextButton.setLabel("Next");
group.add(aRadioButton);
group.add(bRadioButton);
group.add(cRadioButton);
group.add(dRadioButton);
group.add(invis);
aRadioButton.setText("A");
bRadioButton.setText("B");
dRadioButton.setText("C");
cRadioButton.setText("D");
jMenuFile.add(jMenuFileExit);
jMenuHelp.add(jMenuHelpAbout);
jMenuBar1.add(jMenuFile);
jMenuBar1.add(jMenuHelp);
frame.setJMenuBar(jMenuBar1);
newGame.setEnabled(false);
nextButton.setVisible(false);
submitButton.setVisible(true);
submitButton.setLabel("Start");
jMenuHelpAbout.setText("About");

//EXIT GAME ACTION LISTENER


jMenuFileExit.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
Object[] options = {"Quit Viva", "Continue Viva"};
int n = JOptionPane.showOptionDialog(frame,"Do You Wish To
Quit?","Exit App",

JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,
options[0]);
if(n == 0)
{
System.exit(1);
}
}
});

//NEW GAME ACTION LISTENER


newGame.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
nextButton.setVisible(false);
submitButton.setVisible(true);
submitButton.setLabel("Start");
nGame = true;
quesArea.setText("\n\n\tWelcome To Computer Engg. 6 Sem Viva");
invis.setSelected(true);
i = 0;
}
});

//HELP ACTION LISTENER


helptopics.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
helpMethod(0);
}
});

//README ACTION LISTENER


readme.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
helpMethod(1);
}
});
//ABOUT ACTION LISTENER
jMenuHelpAbout.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(frame, "Computer Engg. 6 Sem
Viva\nDesigned By Amol & Indra\nCopyright NPL(C) 2018");
}
});

//ACTION LISTENER FOR THE NEXT QUESTION BUTTON


nextButton.addActionListener(
new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
quesArea.setText(questions[i]);
invis.setSelected(true);
i ++;
submitButton.setVisible(true);
nextButton.setVisible(false);
}
});

//PALCE COMPONENTS ON TO CONTENT PANE


contentPane.add(quesArea, new GridBagConstraints(0, 0, 4, 1, 1.0,
1.0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(22, 24, 0, 19), 0,
144));
contentPane.add(submitButton, new GridBagConstraints(1, 2, 2, 1, 0.0,
0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(13, 83, 25, 19),
29, 7));
contentPane.add(nextButton, new GridBagConstraints(1, 2, 2, 1, 0.0,
0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(13, 81, 25, 21),
43, 7));
contentPane.add(aRadioButton,new GridBagConstraints(0, 1, 1, 1, 0.0,
0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,10,0,0),-3, 0));
contentPane.add(bRadioButton,new GridBagConstraints(1, 1, 1, 1, 0.0,
0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,20,0,0),-3, 0));
contentPane.add(cRadioButton,new GridBagConstraints(3, 1, 1, 1, 0.0,
0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,30,0,0),-3, 0));
contentPane.add(dRadioButton,new GridBagConstraints(2, 1, 1, 1, 0.0,
0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10,40,0,0),-3, 0));

//ALLOW USER TO SUPPLY SERVER'S NAME AND CAPTURE INPUT


System.out.println("This program is a Computer Engg. 6 Sem Viva Exam !!!\n");
System.out.print("\nEnter the Server Name: ");
BufferedReader ser = new BufferedReader(new InputStreamReader(System.in));
server = ser.readLine();

//SET UP SOCKET TO SERVER AND PORT


kkSocket = new Socket(server, 4444);

//SUBMIT BUTTON ACTION LISTNER


submitButton.addActionListener(
new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String fromServer = null;
String fromUser = null;
int inv = 0;
nextButton.setVisible(true);
submitButton.setLabel("Submit");
submitButton.setVisible(false);
newGame.setEnabled(false);

//OPEN STREAMS FROM CLIENT AND TO SERVER


PrintWriter out = null;
BufferedReader in = null;
try
{
out = new PrintWriter(kkSocket.getOutputStream(), true);
in = new BufferedReader(new
InputStreamReader(kkSocket.getInputStream()));
}
catch (UnknownHostException ei)
{
System.err.println("Don't know about host: " + server);
System.exit(1);
}
catch (IOException eo)
{
System.err.println("Couldn't get I/O for the connection to: " +
server);
System.exit(1);
}

//CHECK USER'S INPUT IN RESPONCE TO A QUESTION AND


SEND TO SERVER
try
{
if(aRadioButton.isSelected()) fromUser = "A";
else if(bRadioButton.isSelected()) fromUser = "B";
else if(cRadioButton.isSelected()) fromUser = "D";
else if(dRadioButton.isSelected()) fromUser = "C";
else fromUser = null;
if (fromUser != null)
{
out.println(fromUser);
System.out.println(fromUser);
}
else if(invis.isSelected())
{
if(nGame){}
else
{
JOptionPane.showMessageDialog(frame, "You Must
Make A Selection");
nextButton.setVisible(false);
submitButton.setVisible(true);
inv = 1;
}
}

if(inv == 1)
{
fromServer = null;
submitButton.setVisible(true);
}
else if (nGame)
{
fromServer = ("Press Next to Begin. Goodluck");
nGame = false;
}
else fromServer = in.readLine();

if(fromServer.equalsIgnoreCase("Press Next to Begin.


Goodluck"))
{
Object[] options = {"SE","MCC"};
int n = JOptionPane.showOptionDialog(frame,"Before
You Begin\nChoose Subject","Level",

JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,
options[0]);
if(n == 0)
{
begin = 1;
fromServer = null;
}
else
{
i = 10;
begin = 2;
System.out.println("Begin is " + begin + " i is "
+ i);
fromServer = null;
}
}

if(fromServer != null )
{
quesArea.setText(" ");
if(fromServer.equals("Correct"))
{
JOptionPane.showMessageDialog(frame,
"CORRECT !!!");
quesArea.setText(questions[i++]);
invis.setSelected(true);
correct++;
submitButton.setVisible(true);
nextButton.setVisible(false);
}
else if(fromServer.equalsIgnoreCase("INCORRECT
!!!"))
{
JOptionPane.showMessageDialog(frame,
fromServer);
quesArea.setText(questions[i++]);
invis.setSelected(true);
submitButton.setVisible(true);
nextButton.setVisible(false);
}
else if((fromServer.equalsIgnoreCase("Press Next to
Begin. Goodluck")) || nGame == false)
{
quesArea.setText(questions[i]);
invis.setSelected(true);
submitButton.setVisible(true);
nextButton.setVisible(false);
}
}
}
catch (IOException el)
{
System.err.println("Couldn't get I/O for the connection to: " +
server);
System.exit(1);
}

//CHECK IF END OF GAME


if(i == 11 && begin == 1 || i == 21 && begin == 2)
{
quesArea.setText(" ");
if(i == 41 || i == 21 && fromServer.equals("D"))correct++;
JOptionPane.showMessageDialog(frame, "Viva Over\nGoodbye\nYou
Got " + correct + " Correct.");
correct = 0;
quesArea.setText("\n\tThank You For Giving Viva\n\tTo Select A
New Viva Click File/New Viva\n");
newGame.setEnabled(true);
submitButton.setVisible(false);
nextButton.setVisible(false);
}
}
});

//Center the window


Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height)
{
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width)
{
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height -
frameSize.height) / 2);

//SET UP THE FRAME TO BE VISIBLE TO USER


frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.pack();
}

//METHOD TO SHOW README AND HELP FILES


public static void helpMethod(int i)
{
JFrame frame = new JFrame("Help Topics");
JScrollPane spane = new JScrollPane();
JTextArea htext = new JTextArea();
JPanel pane = new JPanel();
Container ct = frame.getContentPane();
frame.setSize(500,500);
htext.setLineWrap(true);
htext.setWrapStyleWord(true);
spane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAY
S);
spane.getViewport().add(htext, null);
ct.add(spane,BorderLayout.CENTER);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height)
{
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width)
{
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height -
frameSize.height) / 2);
frame.setVisible(true);
frame.show();
try
{
if(i == 1)
{
BufferedReader in = new BufferedReader(new
FileReader("readme.txt"));
frame.setTitle("Read Me");
htext.read(in, " ");
in.close();
}
else {BufferedReader in = new BufferedReader(new
FileReader("helptopics.txt"));
frame.setTitle("Help Topics");
htext.read(in, " ");
in.close();
frame.repaint();
}
}
catch(IOException s)
{
System.out.println("Error");
}
}
}
CONCLUSION
This computer trivia is used by the students to increase the knowledge about the subjects,
reduce the fear of viva from minds. Student will feel it as interesting as multiple students can
connect to the system at once & create gaming (Quiz Game) environment.
FUTURE SCOPE
This is not the overall description about the computer trivia. Some more features can also be
added so as to make trivia more interesting. Further enhancements can be made in designing
the screens more user friendly. Some more features like loading questions through connecting
external database, increasing number of subjects, number & complexity of questions,
sending results on mail, saving results can also be added so as to better the current
application.

REFERENCES
[1] Cricket Trivia Game 3.0

[2] https://www.proprofs.com/quiz-school/story.php?title=pnq

Das könnte Ihnen auch gefallen