Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C#. Create a class called Item which contains the following private variables: string name; // Will be received from files. int weight; //random number

In C#.

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.

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

Step: 3

blur-text-image

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

Evaluate employees readiness for training. page 275

Answered: 1 week ago