Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are working on part of an application for managing role playing games ( RPG ) . The part of the application you are working

You are working on part of an application for managing role playing games (RPG). The part of the application you are working on manages the characters and the campaigns. Your responsibility is to write two classes, called Campaign and FantasyCampaign, that keep track of the characters in a campaign. Characters are represented by objects of the Character class, given on the next page.
The maximum number of characters a campaign can take is passed into the constructor (via a parameter). The Campaign class needs methods to accomplish the following:
1. Add a character (given a Character object), returning true or false to indicate if the addition succeeded (you do not need to check if the character is already in the campaign, duplicate characters are allowed);
2. Drop a character (given a Character object), returning true or false to indicate if the deletion succeeded;
3. Retrieve the number of characters currently in the campaign;
4. Calculate the level of the campaign. The campaign level is calculated by
finding the average of the character levels (rounded down); and
5. Retrieve a textual list of all characters in the campaign, formatted in tab-
separated columns as shown in this example:
400004 Holga 6
400003 Caldor 3
400007 Kira 4
Note that the characters do not need to be stored in any particular order.
For FantasyCampaign objects, we require all the functionality that was described above for Campaign objects. However, for FantasyCampaign objects, we also need to keep track of the name of the magic system it uses (e.g.: hard-rational, hard- irrational, soft-rational, soft-irrational), and well need accessor and mutator methods to retrieve and change the magic system. Also, a fantasy campaigns level is calculated slightly differently. The level is the average character level plus 1 additional level for every 3 characters in the campaign. For example, if the average of the character levels is 5 and there are 8 characters in the campaign then the campaign level is 7(5+2 additional levels).
Write the complete Campaign and FantasyCampaign classes, using the following Character class:
public class Character{
private String characterName;
private final int ID;
private static int currentID =400000;
private int level;
public Character(String characterName, int level){ this.characterName = characterName; this.level = level;
ID = currentID++;
}
public String getCharacterName(){
return characterName;
public int getId(){
}
return ID;
public int getLevel(){
}}
return level;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions