Solved-PROGRAM 3- Solution

$35.00 $24.00

WHAT SHOULD THIS PROGRAM DO? Create a magical creature (or monster) zoo inventory program that will allow a zookeeper to add magical creatures (either manually or from a file), delete a creature, and display all creatures in the zoo. The zoo creatures will be organized in a linked list. FILES THAT SHOULD BE INCLUDED IN…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (2 votes)

WHAT SHOULD THIS PROGRAM DO?

Create a magical creature (or monster) zoo inventory program that will allow a zookeeper to add magical creatures (either manually or from a file), delete a creature, and display all creatures in the zoo. The zoo creatures will be organized in a linked list.

FILES THAT SHOULD BE INCLUDED IN YOUR SUBMISSION

All the following files you will have to create:

  • Zoo.cpp – this file will contain your main function that will allow the user to enter, delete, and print creatures. The main function will create the linked list of creatures.

  • Creature.h – class specification for the Creature class

  • Creature.cpp – class implementation for the Creature class

  • LinkedList.h – a Singly-Linked List template class that you create (DO NOT USE THE LIST CLASS PROVIDED IN THE STANDARD TEMPLATE LIBRARY). All the member functions should be defined in this file as well (either inline or below the class declaration).

  • Makefile – makefile to compile & run the program

The following three files are provided for you in ilearn, but must be included in your submission.

  • RUN.bat – this is the batch file shouldn’t be changed

  • TEST_CASE.txt – this is the test case similar to one that I will use to grade your program. It also shouldn’t be changed.

  • creatureFile.txt – this is the text file that contains creature data in it – the TEST_CASE.txt uses this file.

PROGRAM SPECIFICATIONS (DIRECTIONS ON HOW TO WRITE THE PROGRAM)

LINKEDLIST.H

Create a template class (LinkedList.h) that declares a singly-linked list. This template class should be able to create a linked list of any type of object.

LinkedList class should have the following attributes:

  • A structure (struct) ADT named ListNode, which defines a node with a value & a pointer to the next ListNode.

  • A pointer to a ListNode named head

  • A pointer to a ListNode named tail

  • An integer named numNodes

LinkedList class should have the following member functions:

  • Constructor – should initialize head & tail to point to nothing and initialize numNodes to zero

  • Destructor – like a “RemoveAll” function – should deallocate memory for all existing nodes

  • getLength – should return the number of nodes in the list

  • getNodeValue – this function accepts a position (integer) as a parameter and then returns the value (object) inside the node at that position

  • appendNode – this function accepts a value (object) as a parameter. It creates a new node at the end of the list with the sent object inside of it and increments the number of nodes. This function does not return anything.

  • deleteNode – this function accepts a position (integer) as a parameter, which indicates the position of the node to be deleted. It updates the links of the nodes on either side of this node to be deleted. Then it deletes the node. Then, it decrements the number of nodes.

CREATURE

Create a class specification (Creature.h) & class implementation (Creature.cpp) file for a class named Creature. The purpose of the Creature class is to allow for creation of a Creature object.

Creature should have the following attributes:

  • The creature’s name (string)

  • A description of the creature (string)

  • The cost (float) of the creature (per month) to care for it (food, grooming, destruction, etc)

  • A boolean representing whether the creature is dangerous or not (1 means true – it is dangerous and 0 means false, it is not dangerous)

Creatures should have the following member functions:

  • Constructor – default constructor (doesn’t have to have anything inside it)

  • Constructor with parameters – string, string, bool, & float – should initialize the creature’s attributes

  • Accessor functions

  1. getName

    1. getDescription

    1. getDangerous

    1. getCost

  • Mutator functions

    1. setName

    1. setDescription o setDangerous o setCost

  • printCreature – a function to print a single creature’s information to the screen in a nice, easy to read format

  • printCreatureToFile – a function to print a single creature’s information to the file – unformatted – one piece of information per line. This is so the program would be able to read the creature’s information back later.

ZOO.CPP

This is the driver. This file should have a main function and several other functions to organize or help the main function as described below:

  • main – This function should create a creature linked list, based on the LinkedList template class you create. Then it should display a menu of four options until the user chooses option 4, which is to end the program. Look at sample output to see the flow of the program.

o If user chooses option 1, then a sub-menu should be shown to ask user if they want to enter creatures manually or from file. If manually, then the enterMagicalCreature function should be called, sending the address of the creatureList to this function. If from a file, then the enterMagicalCreatureFromFile function should be called, sending the address of the creature list to this function.

o If user chooses option 2, then the deleteCreature function should be called, sending the address of the creature list to this function.

o If user choses option 3, then the printCreatures function should be called, sending the address of the creature list to this function.

o If user chooses option 4, then the program should ask the user if they want to save their creature list to a file. If user chooses yes, then call the saveCreaturesToFile function, sending the creature list to this function. Print “GOODBYE!” before the program ends.

  • enterMagicalCreature – this function should ask the user for the creature’s name, description, if it is dangerous, and the cost per month to care fo rhte creature. Then it should create a new creature object with this data. Then, it should append the creature object to the linked creature list. Then it should print a confirmation that the creature (print creature’s name) has been added to the zoo. The function should then ask the user if they want to add more creatures. If they answer yes, then repeat this process. Otherwise, the function should end and it doesn’t return any data.

  • enterMagicalCreatureFromFile – this function should ask the user for the name of the file they want to read from. Then, if the file is able to be opened (print a message if can’t be opened) then read the creature data from the file (one at a time) with a loop and after reading in one creature, create a new creature object with this data, then append the creature to the creature linked list. After reading all the creatures from the file & adding them to the linked list, print how many creatures FROM THE FILE were added to the zoo. This may or may not be the current number of creatures in the linked list! This function does not return any data.

  • deleteCreature – this function should first print a numbered list of the names of all the creatures in the linked list. Then ask the user which creature number they want to delete. Then the creature should be removed from the linked list. A confirmation should be printed out that the creature was removed. This function does not return anything.

  • printCreatures – this function should print “THERE ARE NO CREATURES AT YOUR ZOO!” if there are no creatures in the linked list. If there are creatures in the linked list then it should print each creature’s detail in the list. This function does not return anything.

  • saveCreaturesToFile – this function should either print “THERE ARE NO CREATURES AT YOUR ZOO!” if there are no creatures in the linked list. If there are creatures in the linked list then it should ask the user for the filename that they wish to use to save the creatures and then use a loop to get a creature from each node, and then call this creature’s printCreatureToFile function, sending the filename to the function.

MAKEFILE

Create a makefile that will compile the program. Remember that you can’t compile the template class because it automatically gets compiled when a template class object gets created. Name your executable file Zoo.exe.

READABILITY OF OUTPUT & CODE DOCUMENTATION

  • Make sure that your output looks similar to my sample output (below). When I run your program, it shouldn’t make me want to scream. It should be extremely readable and user-friendly.

  • For this program, don’t worry about comments except put your NAME at the top of all files!!!

WHAT TO TURN IN

Zip ALL the files required to compile & run the program, (including the files I provided for you) in a single zipped file named whatever you want. Then, upload this zip file to the assignment folder in ilearn. I will remove one point if you turn in unzipped files. Programs that do not include all the files listed in the “FILES” section above will not be graded.

SAMPLE OUTPUT