
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
Please implement in java code with screenshots of output

Transcribed Image Text:A protocol defines the format of messages exchanged between two computers that
allow the computers to communicate with one another. The table below defines a
protocol for a simple guessing game (\n indicates a newline).
Description
Start or restart a new game.
Quit the game.
Guess a number.
Bad request.
Request (from client)
restartin
quit\n
guess #\n
Anything other than the
above.
Response (from server)
restarted\n
game_over\n
toolow\n
toohigh\n
correct\n
out_of_guesses\n
error\n
For this assignment, you will implement a networked guessing game. The client will
connect to a server, at which point a new game will begin. The client will have a limited
number of guesses to guess a number. The client may start a new game or quit at any
time. Hint: use PrintWriter and BufferedReader to send/receive lines of text
terminated by newlines.
1. Create a GuessingGameServer class that implements the server-side of the
protocol.
a. Wait for a client to connect on port 6355.
b. In a loop, read requests from the client and respond to each request
accordingly.
c. For each new game, a new secret number between 1 and 100 must be
generated. The client will have 6 guesses to guess the number.
ii.
Respond with the appropriate message from the above table.
If the client continues to guess after running out of guesses, treat it
like a bad request.
iii.
The client can restart at any time (even in the middle of a game).
d. If the client quits, the program should exit.
2. Create a Guessing GameClient that provides a command-line interface for the
human user to play a game.
a. The hostname of the server is a command-line argument.
b. Connect to port 6355.
c. Prompt the user to enter guesses.
d. Print the appropriate output to the user (e.g. "Too low!", "Too high!", "Out of
guesses!").
e. If the user quits, send the quit message to the server, close the socket,
and exit the program.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Similar questions
- Make a Java electronic voting program. There should be 4 total parties(people you can vote for) use object-oriented code and output your final result to a text file. Some things to consider: Well implemented variables, data structures, well-running codearrow_forwardThe following code implements a Java Pasta timer that looks like the application below.• Once the start button is pressed the timer will count to two minutes.• The timer can be stopped by pressing stop.• When the timer is finished, it should pop-up an appropriate dialog box that states the timeis up.You are given a partial implementation of program. Fill out the missing code to complete theprogram import javax.swing.*;import java.awt.event.*;import javax.swing.border.*;public class PastaTimerApp extends implements { private JProgressBar progrBar; private JButton startButton, stopButton; private JLabel textLabel; private PastaTimer PastaTimer; public PastaTimerApp() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.setBorder(new TitledBorder("Pasta Timer:")); progrBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 540); textLabel = new JLabel(" 0 Seconds "); p.add(progrBar); p.add(textLabel); // Initialize buttons and add action listeners JPanel controls =…arrow_forwardWrite Java source code to take an integer n and returns the sum of all odd positive integers less than or equals to n. Please implement a sumOddo method for major functionality and a main method with input data for testing cases. Please pay attention to the neat coding style in Java, including grammar, indentations, naming of variables and methods, and comments. a) Conduct an experimental study regarding the running time of your Java code in nanoseconds. Please draw on a separate sheet of paper for the chart/figure on the evaluation results.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY