Question: COSC 143 7 Programming Assignment 2 Programming Assignment 2 You will write a program that reads a binary file that contains records of creatures. Each

COSC 143 7 Programming

Assignment 2 Programming Assignment 2

You will write a program that reads a binary file that contains records of creatures. Each record can be stored in a Creature struct. You should present the user with a menu of three options: display a specific creature, display all the creatures sorted by name, or quit. If the user chooses to display a specific creature, you should ask the user which creature to display.

You will be supplied with a starter file PA 2 _ Starter .cpp. You will need to complete some of the code in main a nd write the definitions for the three functions. For sorting, you should use the sort function found in the algorithm header file. You can read more about this function here:

http://www.cplusplus .com/articles/NhA0RXSz/ .

Make sure you use good programming style.

Name your file PA 2 _lastName_firstName.cpp, replacing lastName with your actual last name and firstName with your actual first name. Submit only the cpp file.

A possible sample run will look as follows:

Menu

1. Display a specific creature

2. Display all creatures sorted by name

3. Quit

Enter your choice (1, 2, 3): 1

Which creature do you want to view?

Enter 1 to 10: 3

Creature Report

Name: Kobold

Type: Small Humanoid

HP: 4

Armor Class: 15

S peed: 6

Press any key to continue . . .

Menu

1. Display a specific creature

2. Display all creatures sorted by name

3. Quit

Enter your choice (1, 2, 3): 1

Which creature do you want to view?

Enter 1 to 10: 8

Creature Report

Name: Frost Worm

Type: Huge Magical Beast HP: 147

Armor Class: 18

Speed: 6

Press any key to continue . . .

Menu

1. Display a specific creature

2. Display all creatures sorted by name

3. Quit

Enter your choice (1, 2, 3): 1

Which creature do you want to view?

Enter 1 to 10: 15

Inva lid entry. Try again.

Which creature do you want to view?

Enter 1 to 10: 2

Creature Report

Name: Orc Type: Medium Humanoid

HP: 5

Armor Class: 13

Speed: 6

Press any key to continue . . .

Menu

1. Display a specific creature

2. Display all creatures sorted by name

3. Quit

Enter your choice (1, 2, 3): 2

Basili s k

Medium Magical Beast

45

16

4

Clay Golem

Large Construct

90

22

4

Ethereal Filcher

Medium Abberation

22

17

8

Frost Worm

Huge Magical Beast

147

18

6

Goblin

Small Humanoid

5

15

6

Harpy

Medium Monstrous Humanoid

31

13

4

Hobgoblin

Medium Humanoid

6

15

6

Kobold

Small Humanoid

4

15

6

Medusa

Medium Monstrous Humanoid

33

15

6

Orc

Medium Humanoid

5

13

6

Press any key to continue . . .

Menu

1. Display a specific creature

2. Display all creatures sorted by name

3. Quit

Enter your choice (1, 2, 3): 3

Press any key to continue . . .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!