Beruflich Dokumente
Kultur Dokumente
“COMPUTER TRIVIVA”
A PROJECT REPORT
Submitted by
AMOL SALUNKHE
INDRAKUMAR VANJARE
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.
The sole intention behind the consideration of this Project is to give viva practice of
various subjects to Students in Quiz format.
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.
Sr No Contents Page No
1 Introduction 7
2 Overall Description 8
4 Screenshots 10
5 Code 12
6 Conclusion 24
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 :
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);
TriviaClient.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.net.*;
JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,
options[0]);
if(n == 0)
{
System.exit(1);
}
}
});
if(inv == 1)
{
fromServer = null;
submitButton.setVisible(true);
}
else if (nGame)
{
fromServer = ("Press Next to Begin. Goodluck");
nGame = false;
}
else fromServer = in.readLine();
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);
}
REFERENCES
[1] Cricket Trivia Game 3.0
[2] https://www.proprofs.com/quiz-school/story.php?title=pnq