C++代写:COMP2150 Movie Database

用C++代写一个Movie Database,相当于开发一个简化版的传统数据库。

CMDB, the C++ Movie Database

For this assignment, you will write the CMDB (C++ Movie Database), which will store information about movies and the actors that have starred in them. Your program will require classes to represent an Actor and a
Movie. The Actor class includes (but may not be limited to) the following information:

  • familyName (string) - the actor’s family name
  • givenName (string) - the actor’s given name
  • birthYear (int) - the year the actor was born
  • gender (?) - actor gender, variable type is your choice

The Movie class includes (but may not be limited to) the following information:

  • title (string) - the title of the movie
  • year (int) - the year the movie was released

Your program will require two lists, one containing actors and one containing movies. Their contents will be read in from a single data file similar to the following:

Nicholson Jack 1937 M
Kidman Nicole 1967 F
Ford Harrison 1942 M

The Shining
1980 Nicholson Jack
The Others
2001 Kidman Nicole
Manufacturing Consent
1992
Chinatown
1974 Nicholson Jack

The file starts out with a list of actors. Each actor is described by four values separated by whitespace (one value for each of the four instance variables described for the Actor class above). The actor data is followed by a single blank line. After the blank line, there is a list of movies. Data for each individual movie occupies two lines: the title of the movie on one line, and additional information on the next. The second line always starts out with the year the movie was released. This may optionally be followed by the name of the movie’s starring actor (family name and then given name). This name will match one of the actors listed in the first part of the file.

You may assume no errors in the data: the file format will be correct, and the named star (if there is one) will exist in the list of actors. A sample input file, a2q1.txt, is provided with this assignment.

Once your program has read in all of the data, it should produce the following output to screen:

  • The list of movies and the actor that starred in them, if any. The movies are to be listed in numerical order of release date. The actor information should include their year of birth and their gender.
  • The name and birth year of every female actoress, and below each actress, the list of all the movies she starred in (if any). The actress list is to be printed in alphabetical order by actress name (order by family name first), and the movie lists should be in numerical order of release date.
  • The name and birth year of every male actor, and below each actor, the list of all the movies he starred in (if any). The actor list is to be printed in alphabetical order by actor name (order by family name first), and the movie lists should be in numerical order of release date.

Actor names are always to be printed with their given names first and family name second. Given the data above, the output produced by your program should be similar to the following:

Movies:
Chinatown (1974) starring Jack Nicholson (1937) M
The Shining (1980) starring Jack Nicholson (1937) F
Manufacturing Consent (1992)
The Others (2001) starring Nicole Kidman (1967) F

Female actors:
Nicole Kidman (1967)
  The Others (2001)

Male actors:
Harrison Ford (1942)
Jack Nicholson (1937)
  Chinatown (1974)
  The Shining (1980)

Since this is a course on object-oriented programming, you are required to use good object-oriented programming techniques. Specifically, you must:

  • Use separate classes for Actor and Movie. These classes will be subclasses of an abstract Object class (see below).
  • Do not create duplicate object instances. Only create one object for each individual movie and actor.
  • Write only one generic linked list class that will be the basis for your data structures. Nodes in the list are to contain a pointer to an Object.
  • The nodes must be either private or protected within the linked list class. Never allow a Node pointer outside of the linked list class hierarchy. The pointer to the top of the list must be private or protected, and a pointer to a Node cannot be returned from any public methods in the class. Try to make the nodes private, rather than protected.
  • Your program design may require you to write subclasses of your linked list class. Your linked list class may be abstract if this fits your solution.
  • The non-object-oriented elements of the program, namely the main() function, should be very minimal. You can use the main function to create an object and call methods on that object. If you want, you can also do your file I/O in this function.

Since C++ does not provide an Object root class like Java does, we will create our own abstract Object class. The objects you store in the linked list descend from this class. It must include at least a virtual destructor as shown in the interface below:

1
2
3
class Object {
public: virtual ~Object() = 0;
};

You may add additional methods to the Object class but keep it as generic as possible.

Some things to note:

  • Your ADTs must be written by yourself: do not use any built-in C++ libraries or any other pre-written classes (of course, string, iostream and ifstream are permitted). If you are not sure if you are allowed to use a certain C++ feature then please ask me.
  • Do not use C-specific features, like C strings (char *), malloc or void pointers (void *), unless it is required by a string or stream method.
  • All your processing should be done in methods, with the exception of a main() function - but keep that function simple.
  • Destroy all heap-based objects you create when they are no longer needed using delete. All heapbased objects must be deallocated by the time your program ends.
  • The classes you write must have their interfaces separate from their implementations, though all your code can be provided in a single file. But you are encouraged to organize class interfaces into individual header files (.h) and provide implementations in source files (.cpp).
  • Do not use or create C++ templated classes or templated functions/methods.

Submission instructions

In order to make the marking of your assignment easier, please follow these submission instructions:

  • Organize all your code files into a single folder and compress the folder into a single zip file.
  • The zip file name must, at the very least, begin with your full name (family name first). For example, someone named John Smith could submit a file named: “Smith_John_assignment.zip” or “Smith_John_COMP2140.zip”.
  • Submit your assignment to the course website’s Dropbox in the appropriate assignment folder. You can submit your assignment multiple times, only the most recent version, and its associated timestamp, will be kept.
  • You must complete the Honesty Declaration Checklist before you can hand in any assignment. Make sure you leave enough time before the deadline to ensure your hand-in works properly.
  • Your code must also adhere to the Programming Standards described on the Course website.

Your zip file must contain:

  • All your C++ source files.
  • The output your program generates from the sample input file, copied and pasted to a file named output.txt
  • A readme.txt file, including:
    • A description of the platform and compiler/IDE you used to develop the program, including version numbers as appropriate. For example, “Windows 10 with Dev-C++ 5 beta” or “U of M Linux with g++”.
    • Instructions on how to compile your code.
    • A brief description of the classes included in your program and their relationships. This description will be used primarily by the marker to aid in navigating your code.

Compatibility issues: In order to reduce potential cross-platform issues when marking, your assignments will be evaluated in a Linux environment that is available to all students. You can develop your code using any OS and IDE you like but your code must compile and run on the aforementioned Linux system with the GNU GCC (g++) compiler if you expect to receive full marks. C++ code does not compile and run the same everywhere. As such, it is strongly recommended that you test your code in the Linux environment before submitting your assignment.

C++ programming hints:

  1. The C++ string class (note the small ‘s’) must be used for strings. To use it, you need to #include <string> at the top of your program. Treat strings the same way you did in Java; that is, declare them using type string (relying on automatic storage), and not through pointers. Avoid using new with strings. This will save you many headaches!

  2. The extraction operator works well enough for reading one value at a time from file but sometimes it is more useful to read entire lines at once. There is a C++ function (not a method!) called getline that is more like Java’s readLine() that can be used instead. Assuming that in is your ifstream and s is a string, the following C++ code will read a line from a file into s: getline(in, s);
    Now if we need to convert the line tokens into integers or other strings, we can use a stringstream.
    First, add #include <sstream> at the top of the code file that will use the stringstream, and then create the stream as follows: stringstream countStream(s); where s is the string that was read from file.

  3. If you write a method that accepts the filename as a string, C++ will complain if you try to use that string to create an ifstream. Given a string filename, open the file with that name using ifstream in(filename.c_str());