Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
D
Distributed Quiz System
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tammam.alsoleman
Distributed Quiz System
Commits
53cff86f
Commit
53cff86f
authored
Nov 18, 2025
by
tammam.alsoleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create the QuizClient
parent
06125aca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
QuizClient.java
src/main/java/org/example/client/QuizClient.java
+65
-0
No files found.
src/main/java/org/example/client/QuizClient.java
0 → 100644
View file @
53cff86f
package
org
.
example
.
client
;
import
org.example.shared.IClientCallback
;
import
org.example.shared.IQuizService
;
import
java.rmi.registry.LocateRegistry
;
import
java.rmi.registry.Registry
;
import
java.util.Scanner
;
public
class
QuizClient
{
public
static
void
main
(
String
[]
args
)
{
try
{
Scanner
scanner
=
new
Scanner
(
System
.
in
);
Registry
registry
=
LocateRegistry
.
getRegistry
(
"localhost"
,
1099
);
IQuizService
server
=
(
IQuizService
)
registry
.
lookup
(
"QuizService"
);
System
.
out
.
print
(
"Enter your name to join the quiz: "
);
String
name
=
scanner
.
nextLine
().
trim
();
IClientCallback
clientCallback
=
new
ClientCallbackImpl
();
server
.
login
(
name
,
clientCallback
);
System
.
out
.
println
(
"Connected successfully! Welcome, "
+
name
);
boolean
running
=
true
;
while
(
running
)
{
System
.
out
.
println
(
"\n--- Menu ---"
);
System
.
out
.
println
(
"1. Get a Random Question"
);
System
.
out
.
println
(
"2. Exit"
);
System
.
out
.
print
(
"Choose an option: "
);
String
choice
=
scanner
.
nextLine
();
switch
(
choice
)
{
case
"1"
:
String
question
=
server
.
getQuestion
();
System
.
out
.
println
(
"\n- Question: "
+
question
);
System
.
out
.
print
(
"- Your Answer: "
);
String
answer
=
scanner
.
nextLine
();
String
feedback
=
server
.
submitAnswer
(
name
,
question
,
answer
);
System
.
out
.
println
(
"- Result: "
+
feedback
);
break
;
case
"2"
:
running
=
false
;
System
.
out
.
println
(
"Exiting... Goodbye!"
);
System
.
exit
(
0
);
break
;
default
:
System
.
out
.
println
(
"Invalid option. Please try again."
);
}
}
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Client exception: "
+
e
.
toString
());
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment