Description
Purpose: This is a development of assignment 1 with the addition of a two ready-made container class templates and overloaded operators. It works in a very similar way. It is a console application that has an AnimationManager that holds a vector template of Animation objects each of which holds a forward_list template of Frames.
In addition the string class is used to hold some of the strings in the application. A string is essentially a vector of chars. Part of the code is shown on the next page; it is also on Brightspace in a text file that you can copy and paste. Because I will use this code when I test your submission, you MUST use this code without modification (not a single character changed): no code added or removed, no new global variables or functions, no new classes, no macros, no defines and no statics.
Your task is to implement, using C++, only the AnimationManager, Animation and Frame class member functions and the global insertion operators and not add any new ones. Everything you write and submit is in the files: AnimationManager.cpp, Animation.cpp and Frame.cpp. When the application runs you can: Add a new Animation to the AnimationManager at the back of the vector Delete a particular Animation Edit a particular Animation to maintain its forward_list of Frames List the AnimationManager to show all its Animations and their Frames Quit An example of the output of the running application is given at the end.
Yours must work identically and produce identical output. Note the following: dynamic memory management is done with new and delete there is no unused dynamic memory at any time input/output is done with cin and cout string objects are used in the AnimationManager and Animation classes to hold names but a cstyle NULL-terminated char array is still used in the Frame class Release of objects’ dynamically allocated memory is done in destructors so there is no resource leak (or you lose 30%) – destructors are never explicitly called. do not #include header files at the top of supplied header files (AnimationManager.h, …etc)
See the Marking Sheet for how you can lose marks, but you will lose marks if: 1. [60% penalty] You change the supplied code in any way at all (not a single character) – no code added or removed, no macros, no defines, no statics and no additional classes, global functions or variables, 2. [60% penalty] It fails to build in Visual Studio 2019, 3. [60% penalty] It crashes in normal operation, 4. It doesn’t produce the example output. You should check the input to lie within a valid range and check the correct functionality of all menu items even if they aren’t actually shown tested in the example output below. Part of the code is shown on the next page.
You MUST use this code without modification. Your task is to add the implementation of the class member functions and friend global functions.
2 What to Submit : Submit this assignment on the Brightspace, as a plain zip file (not RAR or 7-Zip or 9 Zip) containing only AnimationManager.cpp, Animation.cpp and Frame.cpp. The name of the zipped folder must contain your name as a prefix so that I can identify it, for example using my name the file would be tyleraAss2CST8219.zip. It is also vital that you include file headers (as specified in the Submission Standard) in your source files so they can be identified as yours.
Before you submit the code, check that it builds and executes in Visual Studio 2019 as you expect – if it doesn’t build for me, for whatever reason, you get a deduction of at least 60%. make sure you have submitted the correct file – if I cannot build it because the file is wrong or missing from the zip, even if it’s an honest mistake, you get 0. There is a late penalty of 25% per day.
Don’t send me files as an email attachments – they will get 0. Supplied code (also in a text file you can copy and paste on Brightspace). Don’t change it. //Frame.h #pragma once class Frame { char* frameName; double duration; public: Frame(char*, double); Frame(const Frame&); ~Frame(); Frame& operator=(const Frame&); friend std::ostream& operator<<(std::ostream&, Frame&); }; //Animation.h #pragma once class Animation { std::string animationName; std::forward_list frames; public: Animation(std::string name):animationName(name) {} ~Animation() {} void EditFrame(); void
DeleteFrame(); // Add a Frame as in cin >> A; friend std::istream& operator>>(std::istream&,Animation&); // output the Frames as in cout << A; friend std::ostream& operator<<(std::ostream&,Animation&); }; // AnimationManager.h #pragma once class AnimationManager { std::string managerName; std::vector animations; public: AnimationManager(std::string name) :managerName(name) {} ~AnimationManager() {} void EditAnimation(); void DeleteAnimation(); // add an Animation friend std::istream& operator>>(std::istream&, AnimationManager&); // output the Animations friend std::ostream&
operator<<(std::ostream&,AnimationManager&); }; // ass2.cpp #define _CRT_SECURE_NO_WARNINGS #define _CRTDBG_MAP_ALLOC // need this to get the line identification //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF); // in main, after local declarations //NB must be in debug build #include #include #include #include #include using namespace std; #include “Frame.h” #include “Animation.h” #include “AnimationManager.h” int main(void) { char response; bool RUNNING = true; AnimationManager M(“Manager1”);
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); while (RUNNING) { cout<<“MENU\n 1. Add an Animation\n 2. Delete an Animation\n 3. Edit an Animation\n 4. list the Animations\n 5. Quit”<<endl; cin>>response; switch (response) { case ‘1’:cin >> M; break; case ‘2’:M.DeleteAnimation(); break; case ‘3’:M.EditAnimation(); break; case ‘4’:cout << M; break; case ‘5’:RUNNING = false; break; default:cout<<“Please enter a valid option”<<endl; } } return 0; }
3 Example Output MENU 1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations 5. Quit 1 Add an Animation to the Animation Manager Please enter the Animation Name: Animation1 Animation Animation1 added at the back of animations MENU 1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations 5. Quit 1 Add an Animation to the Animation Manager Please enter the Animation Name: Animation2 Animation Animation2 added at the back of animations MENU 1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations
5. Quit 1 Add an Animation to the Animation Manager Please enter the Animation Name: Animation3 Animation Animation3 added at the back of animations MENU 1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations 5. Quit 4 AnimationManager: Manager1 Animation: 0 Animation name is Animation1 Report the Animation No frames in the Animation Animation: 1 Animation name is Animation2 Report the Animation No frames in the Animation Animation: 2 Animation name is Animation3 Report the Animation No frames in the Animation MENU 1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations 5. Quit 3 Which Animation do you wish to edit? Please give the index (from 0 to 2): 1 Editing Animation #1
MENU 1. Insert a Frame 2. Delete a Frame 3. Edit a Frame 4. Quit 1 Insert a Frame in the Animation Please enter the Frame frameName: Frame1 Please enter the Frame duration: 2 Frame Frame1 added at the front of frames MENU 1. Insert a Frame 2. Delete a Frame 3. Edit a Frame 4. Quit 1 Insert a Frame in the Animation Please enter the Frame frameName: Frame2 Please enter the Frame duration: 16 Frame Frame2 added at the front of frames MENU 1. Insert a Frame 2. Delete a Frame 3. Edit a Frame 4. Quit 4 Animation #1 edit complete MENU 1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations 5. Quit
4 3 Which Animation do you wish to edit? Please give the index (from 0 to 2): 0 Editing Animation #0 MENU 1. Insert a Frame 2. Delete a Frame 3. Edit a Frame 4. Quit 1 Insert a Frame in the Animation Please enter the Frame frameName: Frame1 Please enter the Frame duration: 32 Frame Frame1 added at the front of frames MENU 1. Insert a Frame 2. Delete a Frame 3. Edit a Frame 4. Quit 4 Animation #0 edit complete MENU 1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations 5. Quit 4 AnimationManager: Manager1 Animation: 0 Animation name is Animation1 Report the Animation Frame 0: frameName = Frame1; duration = 32 Animation: 1 Animation name is Animation2 Report the Animation Frame 0: frameName = Frame2; duration = 16 Frame 1: frameName = Frame1;
duration = 2 Animation: 2 Animation name is Animation3 Report the Animation No frames in the Animation MENU 1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations 5. Quit 3 Which Animation do you wish to edit? Please give the index (from 0 to 2): 0 Editing Animation #0 MENU 1. Insert a Frame 2. Delete a Frame 3. Edit a Frame 4. Quit 3 Edit a Frame in the Animation There are 1 Frame(s) in the list. Please specify the index (<=0) to edit at : 0 The name and duration of this Frame are frameName = Frame1; duration = 32. What do you wish to replace them with? Frame0 64 Frame #0
edit completed MENU 1. Insert a Frame 2. Delete a Frame 3. Edit a Frame 4. Quit 2 First Frame deleted MENU 1. Insert a Frame 2. Delete a Frame 3. Edit a Frame 4. Quit 3 Edit a Frame in the Animation This are no Frames in the Animation MENU 1. Insert a Frame 2. Delete a Frame 3. Edit a Frame 4. Quit 1 Insert a Frame in the Animation Please enter the Frame frameName: Frame00 Please enter the Frame duration: 128 Frame Frame00 added at the front of frames MENU 1. Insert a Frame 2. Delete a Frame 3. Edit a Frame 4. Quit 4 Animation #0 edit complete MENU
5 1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations 5. Quit 4 AnimationManager: Manager1 Animation: 0 Animation name is Animation1 Report the Animation Frame 0: frameName = Frame00; duration = 128 Animation: 1 Animation name is Animation2 Report the Animation Frame 0: frameName = Frame2; duration = 16 Frame 1: frameName = Frame1; duration = 2 Animation: 2 Animation name is Animation3 Report the Animation No frames in the Animation MENU
1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations 5. Quit 2 Delete an Animation from the Animation Manager Which Animation do you wish to delete? Please give the index in the range 0 to 2: 1 Animation #1 deleted MENU 1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations 5. Quit 4 AnimationManager: Manager1 Animation: 0 Animation name is Animation1 Report the Animation Frame 0: frameName = Frame00; duration = 128 Animation: 1 Animation name is Animation3 Report the Animation No frames in the Animation MENU 1. Add an Animation 2. Delete an Animation 3. Edit an Animation 4. list the Animations 5. Quit