program is to learn to implement binary search trees and to combine their functionalities with linked lists. Program Description In a multiplayer game, players' avatars are placed in a large game scene, and each avatar has its information in the game. Write a program to manage players' information in a multiplayer game using a Binary Search (BS) tree for a multiplayer game. A node in the BS tree represents each player. Each player should have an ID number, avatar name, and stamina level. T

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

*Please using JAVA only*

 

Objective

Program 3: Binary Search Tree Program

The primary objective of this program is to learn to implement binary search trees and to combine their functionalities with linked lists.

Program Description

In a multiplayer game, players' avatars are placed in a large game scene, and each avatar has its information in the game. Write a program to manage players' information in a multiplayer game using a Binary Search (BS) tree for a multiplayer game. A node in the BS tree represents each player. Each player should have an ID number, avatar name, and stamina level. The players will be arranged in the BS tree based on their ID numbers. If there is only one player in the game scene, it is represented by one node (root) in the tree. Once another player enters the game scene, a new node will be created and inserted in the BS tree based on the player ID number. Players during the gameplay will receive hits that reduce their stamina. If the players lose all their stamina, they vanish from the game, and they should be deleted from the tree. You are required to write the following methods:

  1. Write a function to add a new player by adding a new node to the tree.

  2. Write a function to search for a specific player by their ID.

  3. Write a function that prints all the players' names with their specified IDs and stamina

    levels.

  4. Write a function that prints the number of players that existed in the game.

  5. Write a function that updates the stamina level for a specific player when they receive

    hits from another player.

  6. Write a function that removes a particular player from the game by removing their

    node from the tree.

The program deals with three files. Two input files and one output file. The description of these files is as follow:

o The first input file (intialInformation.txt) contains the important information for the program which includes the number of players, the IDs, and the name for each player.

o The information in this file is arranged as follow:
o The first line contains the number of players.
o The following lines contain the players’ IDs and names.

o The commands for the system are found in the second file called commands.txt. The commands in this file are as follow:

o STARTUP: This command will use the first input file (intialInformation.txt) to generate the BS tree by creating a node for each player in the tree.

o ADD_PLAYER: This command has two values that represent the player ID and the player’s name who entered the game scene. The command will create a node in the tree that represents that player in the game. The default value for the stamina level will be 15.

o DISPLAY_PLAYER_INFO:Thiscommandhasonevaluewhichistheplayer ID. It will output the name and the stamina level for the specified player. If the

4

specified player is not found, it will output the “Not found any player with ID

number <ID >” message.
o DISPLAY_ALL_PLAYERS: This command will output all the players in the

game scene with the players’ IDs, names and stamina levels. (Similar to the

output in the ouptput.txt file).
o NUM_OF_PLAYERS: This command will print the total number of players

in the game scene.
o UPDATE_PLAYER_INFO: This command has one value which is the

player ID. It will decrease the stamina level for the specified player by 5 and it will output “the player <name> received a hit and the stamina level reduced by 5” message. If the stamina level for the specified player reaches zero, then the player will be removed from the game, and it will output the “The stamina level for the player <name> reaches zero and <name> left the game!” message. If the specified player is not found, it will output the “Not found any player with ID number <ID >” message.

o DELETE_PLAYER: This command has one value that represents the player’s ID who will leave the game. The command will search for this player in the tree then remove their node from the BS tree, and it will output the “Theplayer <name> left the game” message. If the specified player is not found it will output the “Not found any player with ID number <ID >” message.

o QUIT: This command will stop the program.
o Theoutputoftheprogramshouldbewrittentothefilenameitoutput.txt,whichcontent

should be similar to the contents of the file provided to you.

Implementation

For this program, you will create the following classes:

  • ●  PlayerNode.java: This class will be used to create objects of type player and it will store the player information.

  • ●  GameTree.java: All the methods will be implemented in this class.

  • ●  MainProgram.java: This is the class that will contain the main.

    Sample Input & Output File

    We have provided you a sample for two input files and one output file.

 

 

Image of the output 

Welcome to Game Tree Program
The players existed in the game are:
T ET
PlayerID
Player Name
Stamina level
pumpkin_pie
cute_kitty
Precious
78
15
34
13
18
52
86
blossom
cool_guy
hummingbird
dragon_flames
MasterCheif
15
15
15
15
15
88
15
95
15
Number of players : 8
===============
Player with ID <13> is <Precious> and the stamina level is <15>
Not found any player with ID number <77>
The players existed in the game are:
T ET
PlayerID
Player Name
Stamina level
78
34
13
18
52
pumpkin_pie
cute_kitty
Precious
blossom
15
15
15
15
cool_guy
64
86
88
95
sugar
hummingbird
dragon_flames
MasterCheif
15
15
15
---- ===== =======
The player <blossom> left the game
Not found any player with ID number <22>
The players existed in the game are:
PlayerID
Player Name
Stamina level
78
pumpkin_pie
cute_kitty
Precious
cool_guy
15
15
15
34
13
64
86
sugar
hummingbird
dragon_flames
MasterCheif
15
88
15
95
15
**** :
===== ====
The player <cute_kitty> received a hit and the stamina leve reduced by 5
The player <sugar> received a hit and the stamina level reduced by 5
The player <Precious> received a hit and the stamina level reduced by 5
The player <cute_kitty> received a hit and the stamina level reduced by 5
======:
The stamina level for the player <cute_kitty> reaches zero and <cute_kitty> left the game!"
Not found any player with ID number <44 >
The players existed in the game are:
PlayerID
Player Name
Stamina level
78
13
52
pumpkin_pie
Precious
cool_guy
15
10
15
64
86
88
95
10
sugar
hummingbird
dragon_flames
15
15
MasterCheif
15
Good Bye
Transcribed Image Text:Welcome to Game Tree Program The players existed in the game are: T ET PlayerID Player Name Stamina level pumpkin_pie cute_kitty Precious 78 15 34 13 18 52 86 blossom cool_guy hummingbird dragon_flames MasterCheif 15 15 15 15 15 88 15 95 15 Number of players : 8 =============== Player with ID <13> is <Precious> and the stamina level is <15> Not found any player with ID number <77> The players existed in the game are: T ET PlayerID Player Name Stamina level 78 34 13 18 52 pumpkin_pie cute_kitty Precious blossom 15 15 15 15 cool_guy 64 86 88 95 sugar hummingbird dragon_flames MasterCheif 15 15 15 ---- ===== ======= The player <blossom> left the game Not found any player with ID number <22> The players existed in the game are: PlayerID Player Name Stamina level 78 pumpkin_pie cute_kitty Precious cool_guy 15 15 15 34 13 64 86 sugar hummingbird dragon_flames MasterCheif 15 88 15 95 15 **** : ===== ==== The player <cute_kitty> received a hit and the stamina leve reduced by 5 The player <sugar> received a hit and the stamina level reduced by 5 The player <Precious> received a hit and the stamina level reduced by 5 The player <cute_kitty> received a hit and the stamina level reduced by 5 ======: The stamina level for the player <cute_kitty> reaches zero and <cute_kitty> left the game!" Not found any player with ID number <44 > The players existed in the game are: PlayerID Player Name Stamina level 78 13 52 pumpkin_pie Precious cool_guy 15 10 15 64 86 88 95 10 sugar hummingbird dragon_flames 15 15 MasterCheif 15 Good Bye
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of trees
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education