Question

You are to create a class called Item which contains the following private variables:  string name;  // Will...

You are to create a class called Item which contains the following private variables: 
string name;  // Will be received from files.
int weight;  //random number from 1-10
The class Weapon is derived from Item.  The variable for that class is
int atk;  //random number from 1-10
The class Armor is derived from Item.  The variable for that class is
int def;  //random number from 1-10

You will have 2 files.  One called "Weapons.txt" which has the following:

Sword


Dagger


Bow


Lance


Mace


The "Armors.txt" file has the following data

Helmet


Chest Plate


Mail Vest


Cloth Robe


Shield


Your program should create ONE array of 10 Items (no other arrays will be created and files will be closed after all 10 items are received from file).  The computer will select the order the items are placed in the array Randomly. (You can try getting a random number between 1 and 2, if it is a 1 you place the next weapon from file while if it is a 2, you place the next armor... though be aware there will be a time when you already received all items from either the weapon or armor file, in which case you get the remainder items from the non-empty file to fill in the rest of the array).
You should then sort the Items based on Damage per minute and Armor per minute (do not separate the weapons and armors from the array, you will sort based on the DPM and APM numeric value).  Basically some math will need to be done to get these values based on the following.
if the weight is 1, he can attack 10 times per minute.  for each extra weight, he can attack one time fewer as shown in the following (defense works with similar formula):

Weight = 1, 10 attacks per minute.


Weight = 2, 9 attacks per minute.


Weight = 3, 8 attacks per minute.


Weight = 4, 7 attacks per minute.


Weight = 5, 6 attacks per minute.


Weight = 6, 5 attacks per minute.


Weight = 7, 4 attacks per minute.


Weight = 8, 3 attacks per minute.


Weight = 9, 2 attacks per minute.


Weight = 10, 1 attack per minute.


This means if the random number for weight is 7, he can attack 4 times in one minute.  This multiplied by the weapon atk gives you the damage per minute.
Display (Neatly) all the content of the Item array on the screen( name, weight, atk/def and attack/armor per minute).  You will then send the following to the Screen:
1.  The weapon with the strongest Damage per minute along with the name, weight, attack and damage per minute.
2.  The armor with the strongest Armor per minute along with the name, weight, defense and armor per minute.

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
You are to create a class called Item which contains the following private variables:  string name;  // Will...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You are to create a class called Item which contains the following private variables:  string name;  // Will...

    You are to create a class called Item which contains the following private variables:  string name;  // Will be received from files. int weight;  //random number from 1-10 The class Weapon is derived from Item.  The variable for that class is int atk;  //random number from 1-10 The class Armor is derived from Item.  The variable for that class is int def;  //random number from 1-10 You will have 2 files.  One called "Weapons.txt" which has the following: Sword Dagger Bow Lance Mace The "Armors.txt" file...

  • The FoodItem.java file defines a class called FoodItem that contains instance variables for name (String) and...

    The FoodItem.java file defines a class called FoodItem that contains instance variables for name (String) and calories (int), along with get/set methods for both. Implement the methods in the Meal class found in Meal.java public class FoodItem{ private String name; private int calories;    public FoodItem(String iName, int iCals){ name = iName; calories = iCals; }    public void setName(String newName){ name = newName; }    public void setCalories(int newCals){ calories = newCals; }    public int getCalories(){ return calories;...

  • using C++ Requirements: . Classes you must create o Monster must be an abstract class Each monster has . an attack) o randomly generate a number between 0 and strength for each attack (Strength 10 wo...

    using C++ Requirements: . Classes you must create o Monster must be an abstract class Each monster has . an attack) o randomly generate a number between 0 and strength for each attack (Strength 10 would generate 0-10) add up all the damage done return total damage o o e a number of attacks . a number for strength used during attacking . a string representing the type » accessor for type o Goblin inherits from Monster type is "Goblin"...

  • Create a java class for an object called Student which contains the following private attributes: a...

    Create a java class for an object called Student which contains the following private attributes: a given name (String), a surname (family name) (String), a student ID number (an 8 digit number, String or int) which does not begin with 0. There should be a constructor that accepts two name parameters (given and family names) and an overloaded constructor accepting two name parameters and a student number. The constructor taking two parameters should assign a random number of 8 digits....

  • I am having an issue adding in the following strenght and defense criteria. *Mob, *charm, *Hogwarts....

    I am having an issue adding in the following strenght and defense criteria. *Mob, *charm, *Hogwarts. Can you help please? Requirements In this project, you will create a simple class hierarchy as the basis for a fantasy combat game. Your ‘universe’ contains Vampires, Barbarians, Blue Men, Medusa and Harry Potter. Each has characteristics for attack, defense, armor, and strength points as follows. Type Attack Defense Armor Strength Points Vampire1 1d12 1d6* Charm 1 18 Barbarian2    2d6 2d6 0 12 Blue...

  • Need this in C The starter code is long, if you know how to do it...

    Need this in C The starter code is long, if you know how to do it in other way please do. Do the best you can please. Here's the starter code: // ----------------------------------------------------------------------- // monsterdb.c // ----------------------------------------------------------------------- #include #include #include // ----------------------------------------------------------------------- // Some defines #define NAME_MAX 64 #define BUFFER_MAX 256 // ----------------------------------------------------------------------- // Structs typedef struct { char name[NAME_MAX]; int hp; int attackPower; int armor; } Character; typedef struct { int size; Character *list; } CharacterContainer; // ----------------------------------------------------------------------- //...

  • Problem 5: Monster Factory (10 points) (Game Dev) Create a Monster class that maintains a count...

    Problem 5: Monster Factory (10 points) (Game Dev) Create a Monster class that maintains a count of all monsters instantiated and includes a static method that generates a new random monster object. In software engineering, a method that generates new instances of classes based on configuration information is called the Factory pattern. UML Class Diagram: Monster - name: String - health: int - strength: int - xp: int + spawn(type:String): Monster + constructor (name: String, health: int, strength: int, xp:...

  • *IN PYTHON* A role-playing game or RPG is a game in which players assume the roles...

    *IN PYTHON* A role-playing game or RPG is a game in which players assume the roles of characters in a fictional setting. The popularity of the epic saga told in J.R.R. Tolkien's The Hobbit and The Lord of The Rings greatly influenced the genre, as seen in the game Dungeons & Dragons and all of its subsequent variants. In most RPGs, a player creates a character of a specific archetype or class, such as "Fighter", "Wizard", or "Thief". (Note: do...

  • create case 4 do Method 1:copy item by item and skip the item you want to...

    create case 4 do Method 1:copy item by item and skip the item you want to delete after you are done, delete the old file and rename the new one to the old name. #include int main(void) { int counter; int choice; FILE *fp; char item[100]; while(1) { printf("Welcome to my shopping list\n\n"); printf("Main Menu:\n"); printf("1. Add to list\n"); printf("2. Print List\n"); printf("3. Delete List\n"); printf("4. Remove an item from the List\n"); printf("5. Exit\n\n"); scanf("%i", &choice); switch(choice) { case 1:...

  • (a) FileIO In the FileIO class add a public static method named writeCharacter. This method takes...

    (a) FileIO In the FileIO class add a public static method named writeCharacter. This method takes as input a Character to write, and a String which is the filename to write to. Within this writeCharacter method, use the FileWriter and BufferedWriter objects to write the character’s information back to a file. Make sure to catch the IOException when writing a file, and throw an IllegalArgumentException with an appropriate error message. If you prefer, you can also use the throws statement...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT