Question: Massive Multiplayer Online Role Playing Game Object (MMORPG.cpp) In this lab, you will create an object that handles the players in a Massive Multiplayer Online

Massive Multiplayer Online Role Playing Game Object

(MMORPG.cpp)

In this lab, you will create an object that handles the players in a Massive Multiplayer Online Role Playing Game (MMORPG). Even if you are not a hard-core gamer, and unfamiliar with MMORPG concepts, you can still create this object.

The UML for the Game object is:

Game

-maxPlayers : int

-humans : int

-avatars : int

-bandwidth : int

-gameTime : int

-setGameTime(void):void

-setBandwidth(void):void

+Game()

+Game(maxPlayers : int, humans : int, avatars : int)

+setMaxPlayers(maxPlayers : int): void

+setHumans(humans : int): void

+setAvatars(avatars : int): void

+addPlayer(player : int): void

+getMaxPlayers(): int

+getHumans(): int

+getAvatars(): int

+getGameTime(): int

+getBandWidth(): int

+printInfo():void

There are some basic rules to this object, namely,

You can never have negative values for maxPlayers, humans, and avatars (computer-generated players)

You must always have at least one human player, so humans are never less than 1 (same for maxPlayers)

You can have 0 avatars.

The number of human players can never exceed the number of maxPlayers.

The sum of your humans and avatars must never be greater than maxPlayers. If it is, you must diminish the avatar count.

Bandwidth is measured in Gigabits. You need 100 Gigabits for every avatar, and 200 Gigsbits for every human. Each time you change the number of humans and/or avatars, you must recalculate the bandwidth (using the private facilatator setBandwidth() method)

Whenever there are more avatars than humans, the game time is set to 200 seconds. Otherwise it is set to 400 seconds. Each time you change the number of humans and/or avatars, you must recalculate the bandwidth (using the private facilatator setGameTime() method)

Whenever you create an object, or change the numbers of humans players and/or avatars, you must ALWAYS recalculate the Band Width and Game Time.

The method printInfo() will printout out the number of Max Players, the number of humans, the number of avatars, the band width needed, and the time of game play (Game Time)

You will create a game object, and set the attributes with the appropriate methods, namely:

The default constructor will set the maxPlayer to 1, and the humans to 1.

The constructor object will set the number of maxPlayers, humans, and avatars. No matter what the user enters, you must have at least 1 maxPlayer, and 1 human player.

The other methods are self explanatory, but the addPlayer(int player) is different: you can add that number of human players provided the total does not exceed the maxPlayers limit. If you enter a negative number, you can REMOVE human players provided you still have at least one human player

Create the following lines of code in main:

Game myGame1 = Game(); // this creates a game with 1 maxPlayer,

// 1 human, and 0 avatars

Game myGame2 = Game(3, 2, 6); // this creates a game with 3 maxPlayers,

// 2 humans, and 1 avatar (the user specified

// 6, but you are only allowed a max of 3, and 2

// are already claimed by the humans

Game myGame3 = Game(4, -3, 2); // this creates a game with 4 maxPlayers,

// 1 human (you are not allowed less than 1),

// and 2 avatars

Game myGame4 = Game(-8, -3, 2); // this creates a game with 1 maxPlayers,

// 1 human (you are not allowed less than 1),

// and 0 avatars

You will print out the data using the .printInfo() method, which will produce output something like:

MMORPG Info:

Max Players: 5

Humans : 2

Avatars : 1

Band Width : 500 Gigabits

Game Time : 400 Seconds

 
// Filename: MMORPG.cpp
// Author: Your Name 
// CS&P Lab 15
// Description: Create a game object, with players, humans, and avatars, 
// and calculate bandwidth and game time play, as well as reporting 
// the appropriate printInfo data 
// Written: April 18, 2018
 
#include 
#include 
#include 
// and any other libraries you need
 
using namespace std;
 
// Game object definitions must go here first 
// before main
 
int main()
{
 /* ... Your main program goes here ... */
 
 cin.ignore();
 cin.get();
 return EXIT_SUCCESS;
}
 
 
 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!