Answered step by step
Verified Expert Solution
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:
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;
Drop a character given a Character object returning true or false to indicate if the deletion succeeded;
Retrieve the number of characters currently in the campaign;
Calculate the level of the campaign. The campaign level is calculated by
finding the average of the character levels rounded down; and
Retrieve a textual list of all characters in the campaign, formatted in tab
separated columns as shown in this example:
Holga
Caldor
Kira
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 eg: hardrational, hard irrational, softrational, softirrational 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 additional level for every characters in the campaign. For example, if the average of the character levels is and there are characters in the campaign then the campaign level is 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 ;
private int level;
public CharacterString 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started