PROG1385 – A-02 : THE DISNEYCHARACTER CLASS Solved

65.00 $

Description

5/5 - (1 vote)

OVERVIEW

Believe it or not, you have all had the lessons necessary to begin writing your own classes!  One of the scariest things is to do it for the first time … this exercise will ease you through it.  In order to minimize the scary factor – you will be developing a class to model Disney

Characters (Mickey, Minnie, etc.) – because hey – there’s nothing scary about Mickey Mouse! (Right? J)

In this exercise, you will be

  • Getting the chance to use source-code repositories again (as you did in SEF last semester) to store your code for this assignment.
    • NOTE: You do not need to use an RCS if you don’t want the practice – but it is a good idea…
  • Developing 3 source files to store in your repository o h – the file that contains the class definition for this exercise
    • cpp – the source file that contains the method bodies (the code) for the class o testDisneyCharacter.cpp – your testharness (main function) which you will use to test your class

The requirements description below give you details on the DisneyCharacter class in terms of the data-members of the class as well as the methods.

This is an individual assignment and must be completed by you alone

 

OBJECTIVES

This assignment supports and reinforces the following objectives:

  • Understand and implement Object-Oriented language and design principles
  • Use the C++ syntax to design and define classes and use them in assignments and projects

 

ACADEMIC INTEGRITY AND LATE PENALTIES

EVALUATION

  • Please refer to the assignment weighting in the Instructional Plan for the course as well as the assignment’s Rubric in the course shell.

PREPARATION

Review Module-04, Module-05 and Module-06 (lesson content, videos as well as the sample source code) for an understanding of how layout and code your first class definition.

USING A SOURCE CODE REPOSITORY – SETTING IT UP

Do you want to get some more practice at using a Source Code Repository (RCS – as we discussed and used last semester in SEF)?  If so – then you can on this assignment!  If not – that’s okay too – simply move onto the “Requirements” section below.

Connecting to your Source Repository and Checking in the Initial Solution

  1. Follow the instructions in the Creating-A-RiouxSVN-Repository document as well as the Installing-Tortoise-SVN document in order to create and prepare your computer for connecting to your personal repository code space. These documents are found in the

Course References area of the course content.  [NOTE: You most likely have already setup the Tortoise-SVN last semester in SEF]

  1. As instructed in the Installing-Tortoise-SVN document, create a local directory on your computer and call it C:\SETRepo
  2. Connect to your repository (remembering your repository’s URL and your login credentials using the Tortoise SVN client and perform an SVN Checkout)
  3. Now start Visual Studio (VS) and create an empty project called DisneyCharacter in the C:\SETRepo\ directory (as show in Diagram 1 at the end of this document)
  4. Let’s setup the skeleton of the source files for this project …
    • Add a file called h to the Header Files section in the VS Solution.
    • Add a file called cpp to the Source Files section in the VS Solution and
    • Also add a file called cpp to the Source Files
    • This is shown in Diagram 2 at the end of this document – just so that the files weren’t empty, I placed a single line comment at the start of each file. You do the same.
  5. The reason I wanted to ensure that the source files weren’t empty is because I want to add and commit the files to my repository now
  6. When adding VS solutions to a repository – you do not want to add all files that are generated by VS.  This is because some of the files change each and every time you open the solution, or are different on different people’s computers …
    1. Imagine you were working on a project with a number of other people – all from the same source files. If all VS files were committed – then each and every member of the team would have commits to do every time they opened the project – even if they made no source code changes!!
  7. So now – save the VS solution and project and exit VS. Go to the C:\SETRepo\DisneyCharacter folder and erase the DEBUG folder.  Then go into the C:\SETRepo\DisneyCharacter\DisneyCharacter folder and erase that DEBUG folder. You do not need or want these 2 folders in your golden copy of the repository,
    1. As well, if you venture into the C:\SETRepo\DisneyCharacter\.vs folder (which is hidden) and drill further down into the “…DisneyCharacter\v16\” folder, you may very well see a folder titled ipch. Erase this folder – this is where VS hides the incremental pre-compiled header files … these files take up unnecessary space in your repository.  Also erase the VC.db file – it is not necessary either.
    2. Once you’ve erased these files and folders – go back to the C:\SETRepo folder and right-click on the top-level

DisneyCharacter folder (as shown in Diagram 3)

  1. Choose the Tortoise-SVN option from the pop-up and the Add  option from the sub-menu – follow the prompts
  2. Right-click on the same folder again and select SVN Commit – remember when prompted for a commit comment – we want to follow best practices – so give it a comment … perhaps “initial commit of DisneyCharacter solution and project directory structure and files”
  1. Now your VS Solution and Project are ready to go, you have skeleton source files and they have been added to your repository …
    1. You are ready to proceed to the Requirements section below – the class definition requirements and coding …
    2. After you’re done coding (or you simply want to update your source code repository) refer to the section titled “USING A SOURCE CODE REPOSITORY – UPDATING YOUR CODE” below for instructions on saving (updating) your code in your repository (if you complete this exercise over multiple programming sessions).

 

 

REQUIREMENTS  

This should be a simple one … I want you to write a class definition for a class to be known as DisneyCharacter.  Here are the particulars of the class:

The Class Particulars

  • The class has the following data members

name

  • a string[1] of maximum 50 characters
  • if upon construction of the DisneyCharacter object or modification of the name data-member, the name is being set to a string longer than 50 character – you need to truncate the string at 46 characters and append the character sequence “ …” to the end (that is a leading space before the “…”

creationDate

  • a string of the format yyyy-mm-dd (example value  “2012-01-30”)

numMovies

  • an integer representing the number of movies that the character has been in

whichPark

  • a single character value indicating which of the DisneyWorld / DisneyLand parks the character can be found in – allowable values are:
    • ‘M’ for Magic Kingdom
    • ‘S’ for Disney Studios
    • ‘A’ for Animal Kingdom
    • ‘E’ for Epcot
    • ‘C’ for California Adventure
    • ‘N’ to indicate the character is not placed
    • The class should have the following methods o a constructor which takes values for all 4 data-members and sets them
  • need to ensure that the name string length is not exceeded – otherwise do as required
  • need to ensure that incoming value for whichPark data member is valid. If not, mark the character as Not Placed.
  • need to ensure that incoming value for numMovies is greater than or equal to zero. If not, set to zero.
  • need to ensure that incoming value for creationDate is in the required format. If not, leave blank o a constructor which takes only the name and creationDate data-members and defaults the numMovies data-member to a value of 0, and the whichPark data-member to ‘N’
  • need to ensure that the name string length is not exceeded – otherwise do as required
  • need to ensure that incoming value for creationDate is in the required format. If not, leave blank
You must create these 2 constructors – I want you to overload the constructors.  Do not create 1 constructor with default
values for the numMovies parameter and the whichPark parameter  
  • no other input validation is necessary in this constructor o
  • You need to create a destructor
    • which prints out message to say “<name data-member> destroyed.” When invoked
      • g if the DisneyCharacter is “Tigger” then it states “Tigger destroyed”
    • accessors for each of the data-members o a mutator for each of the numMovies and whichPark data-members
      • your mutator’s – like good mutators should perform validation on the incoming parameter value
      • and only set the data-member’s value if the incoming value is valid
      • if the value is not valid – then the current value for the data-member is left alone
      • your mutator should also return a bool data-type to indicate whether the incoming value was valid or not o also declare the following public methods
      • void ShowInfo(void) – this method is called in order to print out the current value of all of the data members for the object
        • In presenting the information to the user … think like the user … what makes sense – what would be understandable to them?
        • This method would be similar to void DogDump(void) in Module-06’s The ClassicDog example
      • bool PlaceCharacter(char whichPark) – this method is called in order to place or position the character at a particular park

§ void SameMovies(DisneyCharacter& anotherCharacter) – this method is called upon to set the

number of movies that this Disney Character has been in to the same number of movies as the specified character (from the parameter list)

  • Please follow and use best practices in your class design in terms of encapsulation
  • Place only the class definition in the .H file and place all of the method body code in the .CPP file
  • Commenting the source code is not required in this exercise. You can choose to comment the code (to practice) if you like, but the comments will not be marked.     

The Test-Harness Particulars

  • Your testharness source code module (i.e. your main() function) is called upon to use the DisneyCharacter class interactively. In this code:
  • Instantiate a DisneyCharacter object called mickey (i.e. name=“Mickey”, creationDate=”1929-01-01”, numMovies=100, whichPark=’M’)
  • Instantiate a DisneyCharacter object called minnie  (i.e. name=“Minnie”, creationDate=”1930-01-01”) o try setting the number of Minnie’s movies equal to Mickey’s by calling the SameMovies() method
  • Question: Which object (Minnie or Mickey) is this method called on – and which object (Minnie or Mickey) is passed into it as a parameter?
  • try dumping out the object’s member values by calling ShowInfo() – for both Mickey and Minnie o try placing Minnie in the Epcot park.

 

FILE NAMING REQUIREMENTS

You will create and submit only the following files:

• testDisneyCharacter.cpp • DisneyCharacter.cpp •DisneyCharacter.h

 

SUBMISSION REQUIREMENTS

Please ZIP up only the required files and submit to the appropriate eConestoga Dropbox by the deadline.

 

 

USING A SOURCE CODE REPOSITORY – UPDATING YOUR CODE

Putting your Code back into the Repository

Once you’re done programming the exercise – or just want to take a break … you need to save it to your repository.  So save all open files in VS and exit it.

  • Using Windows Explorer – go back to C:\SETRepo
  • You should notice that the Tortoise SVN icons on the folders and files have changed o You may see something like Diagram 4 (at the end of this document)
  • When committing your source code changes to any repository, best practices say that you need to commit each individual source code file (i.e. each .H and .CPP (or whatever language you are programming in)) by itself o We do this so that our commit message to the repository (which becomes part of the file’s change log) is specific to the changes that you made in that file and that file alone!

o So go into your C:\SETRepo\DisneyCharacter\DisneyCharacter directory and right-click SVN-Commit

  • On h – enter a commit comment specific to the changes you made in that file
  • On cpp – enter a commit comment specific to those changes and finally
  • On cpp – and enter a commit comment specific to that file o You would do this individual file level commit for all files (usually source file) that you care to have individual commit messages on. In larger system solutions, this may also include configuration files, text files, etc.
  • Just as a catch-all commit after you’ve commited each source file – go back to the C:\SETRepo directory o It might be a good idea – until you get the hang of a repository to go back to the top-level directory of your solution (after you’ve committed the individual files that you know you’ve changed separately) and do a right-click SVN Commit here
  • So – you should be in C:\SETRepo and you right-click and commit on the top-level DisneyCharacter folder • If there really are no more modified files (i.e. files which are different in your local copy than in the repository) – then the commit “files” window will be blank – and you’re done!
  • If there are some files that are different in your local copy – they should be VS administration-type files only – and these are safe to commit en-masse with one commit comment

 

USING A SOURCE CODE REPOSITORY – DIAGRAMS

These are the screen captures / diagrams that go along with you using the Source Code Repository for this assignment.  [NOTE: Some of these screen captures were taken on a previous version of Visual Studio – but they are still applicable]

 

Diagram 1: Making sure to create the VS project within the signed out repository

 

Diagram 2: Creating stub source files so we can add the files to the repository

 

 

Diagram 3: Adding the initial DisneyCharacter directory structure and files

 

Diagram 4: After the coding … Tortoise SVN indicates what has changed …

 

[1] You can choose to use a char[] for this data member or a string object … either way, you still need to be able to limit the maximum length to 50 characters …

  • A2-yqncwm.zip