Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Required Enums Create and implement the following enumerations. 1. State Opened Closed Locked 2. LockType Novice Intermediate Expert 3. Material Oak Iron Gold 4. LootQuality

image text in transcribedimage text in transcribed

Required Enums

Create and implement the following enumerations.

1. State

Opened

Closed

Locked

2. LockType

Novice

Intermediate

Expert

3. Material

Oak

Iron

Gold

4. LootQuality

Grey

Green

Purple

Required Functions

Implement all functions that have throw new NotImplementedException();

1. ManipulateTreasureChest

See Task 2 in the instructions.

2. GetLockType

Returns the enum value for LockType based on user input. If the user inputs an invalid option, set the LockType to Novice. 3. GetMaterial

Returns the enum value for Material based on user input. If the user inputs an invalid option, set the Material to Oak. 4. GetLootQuality

Returns the enum value for LootQuality based on user input. If the user inputs an invalid option, set the LootQuality to Grey.

Example Output

1. Creating the chests:

2. Writing the chests:

3. Manipulating the chests:

---the program.cs file whre code should be inputteed is here: this should be done in C# not in java or python--

using System;

namespace ConsoleApp1 { class Program {

// declare enumerations here public static void Main(string[] args) { // declare array here

//Uncomment these functions out when ready: //CreateChests(); //ManipulateTreasureChest(); }

public static void CreateChests((Enum state, Enum lockType, Enum material, Enum lootQuality)[] chests) { for(int i = 0; i

foreach(var chest in chests) { Console.WriteLine(); Console.WriteLine("---------------------------"); Console.WriteLine("A chest with the following properties has been created: "); Console.WriteLine("Material: " + chest.material); Console.WriteLine("Lock Type: " + chest.lockType); Console.WriteLine("Loot Quality: " + chest.lootQuality); Console.WriteLine("---------------------------"); } }

public static (State, LockType, Material, LootQuality) GetChest((Enum, Enum, Enum, Enum) chest) { State startingState = State.Locked; LockType startingLockType = GetLockType(); Material startingMaterial = GetMaterial(); LootQuality startingLootQuality = GetLootQuality(); return (startingState, startingLockType, startingMaterial, startingLootQuality); }

///

/// This method allows a user to go between the states of opening, locking and unlocking a treasure chest. /// If an invalid state transition is given, the state of the chest remains unchanged. /// public static void ManipulateTreasureChest((Enum state, Enum lockType, Enum material, Enum lootQuality) singleChest) { throw new NotImplementedException(); }

///

/// Allows the user to choose a lock type for the chest. Defaults to intermediate if the user input is invalid. /// /// An enum representing the lock type that the chest will possess. public static LockType GetLockType() { throw new NotImplementedException(); }

///

/// Allows the user to choose a material for the chest. Defaults to oak if the user input is invalid. /// /// An enum representing the material from which the chest will be created. public static Material GetMaterial() { throw new NotImplementedException(); }

///

/// Allows the user to choose the quality of the loot contained within the chest. Defaults the grey loot quality if the user input is invalid. /// /// /// An enum representing the quality of the loot within the chest. public static LootQuality GetLootQuality() { throw new NotImplementedException(); } } }

Introduction All code should be added to the Program.cs file provided in the Moodle section for this assignment. Task 1 Write a program that uses tuples and enumerations that allows the user to create different types of treasure chests. Task 2 Create a program with enermations that allows the user to go between the states of opening, closing, locking, and unlocking a treasure chest. Instructions Task 1: 1. Define the required enumerations. 2. In Main, create a tuple array of length 3 that represent the treasure chests where each tuple is composed of each enumeration. 3. Implement the GetMaterial, GetLockType, and GetLootQuality functions that allow for the users to select the value for each enumeration. 4. When ready (and in Main), correctly call the CreateChests function. Task 2: Implement the following code in ManipulatreTreasureChest 1. Write code that allows the user to manipulate the chest by opening, closing, locking, and unlocking the chest. - Make sure the user can't perform incompatible steps (example: Opening a lock chest, locking an opened chest, etc.) 2. Loop asking for the next command until the user enters the command 5. 3. When ready (and in Main), correctly call the ManipulatreTreasureChest function

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Did the team members feel that their work mattered

Answered: 1 week ago

Question

3. What may be the goal of the team?

Answered: 1 week ago