Language is C++ Assignment 8 A: Rare Collection. We can make arrays of custom objects just like we’ve done with ints and strings. While it’s possible to make both 1D and 2D arrays of objects (and more), for this assignment we’ll start you out with just one dimensional arrays. You have been commissioned to develop a program to digitally record a rare collection of LaserDisc movies. You will start by creating a LaserDisc class. It should have the following private attributes: String movieTitle int releaseYear String genre float rating Your class should also have the following methods: Default Constructor: Initializes the four attributes to the following default values: ◦ movieTitle = “Star Wars Holiday Special” ◦ releaseYear = 1978 ◦ genre = “Science Fiction” ◦ rating = 5.0 Overloaded Constructor: Initializes the four attributes based on values passed into the formal parameters ◦ If rating is less than 0.0 or greater than 5.0, set it equal to 0.0 ◦ If releaseYear is less than 1978, set it equal to 1978 bool/Boolean isItGood(): Returns “true” if rating is 3.0 or greater, and “false” otherwise. Getter method for all class attribute You will then create a separate class, Assignment8A. In its main method, you should do the following: Ask the user how many movies are in their collection Create an array (of type LaserDisc) of that size Use a loop to ask the user to enter information for all movie ◦ Create a LaserDisc object for each movie and store it in the next index in the array Then using another loop, you should give the user the following options: Print movie information ◦ This should ask the user for a number, and then print the information from the LaserDisc object at that index. If the index is out of bounds, it should notify the user instead. Recommend a good movie from the collection ◦ This should choose a random movie, check if it is a good movie based on the relevant function, and either print the information to the user or guess again if it was not a good movies If there are no good movies in the collection, tell the user that no good movies exist in the collection. Hint: You can use a counter variable to keep track of the guesses. When you’ve guessed more times than numbers of elements in the array, you can stop. However, this means you might miss some movies if the same index is randomly selected multiple times. If you want to challenge yourself further, consider another way you could handle that situation. Quit ◦ Ends the loop and the program (user input is in bold)Sample Output: [Laser Disc Collection] How many movies do you have? 10 Movie 1: *Enter Title: Back to the Future *Enter Genre: Science Fiction *Enter Release Year: 1985 *Enter Rating: 5.0 Movie 2: *Enter Title: Twin Peaks Season 1 *Enter Genre: Mystery-Horror Serial Drama *Enter Release Year: 1992 *Enter Rating: 4.5 //Keep going for all 10 movies (THIS IS NOT PART OF THE OUTPUT) [Main Menu] 1) Movie Info 2) Recommend a Good Movie 3) Log off Choice: 1 Which Movie do you want? 100 Sorry, that’s not a valid Movie index [Main Menu] 1) Movie Info 2) Recommend a Good Movie 3) Log off Choice: 1 Which movie do you want? 0 0. Back to the Future, 1985 Genre: Science-Fiction Rating: 5.0 [Main Menu] 1) Movie Info 2) Recommend a Good Movie 3) Log off Choice: 2 You should try: Dune (1984)! It has a rating of 4.1 [Main Menu] 1) Movie Info 2) Recommend a Good Movie 3) Log off Choice: 3 Goodbye!
Language is C++
Assignment 8 A: Rare Collection. We can make arrays of custom objects just like we’ve done with ints and strings. While it’s possible to make both 1D and 2D arrays of objects (and more), for this assignment we’ll start you out with just one dimensional arrays. You have been commissioned to develop a program to digitally record a rare collection of LaserDisc movies. You will start by creating a LaserDisc class. It should have the following private attributes:
String movieTitle
int releaseYear
String genre
float rating
Your class should also have the following methods:
Default Constructor: Initializes the four attributes to the following default values:
◦ movieTitle = “Star Wars Holiday Special”
◦ releaseYear = 1978
◦ genre = “Science Fiction”
◦ rating = 5.0
Overloaded Constructor: Initializes the four attributes based on values passed into the formal parameters
◦ If rating is less than 0.0 or greater than 5.0, set it equal to 0.0
◦ If releaseYear is less than 1978, set it equal to 1978
bool/Boolean isItGood(): Returns “true” if rating is 3.0 or greater, and “false” otherwise.
Getter method for all class attribute
You will then create a separate class, Assignment8A. In its main method, you should do the following:
Ask the user how many movies are in their collection
Create an array (of type LaserDisc) of that size
Use a loop to ask the user to enter information for all movie
◦ Create a LaserDisc object for each movie and store it in the next index in the array
Then using another loop, you should give the user the following options:
Print movie information
◦ This should ask the user for a number, and then print the information from the LaserDisc object at that index. If the index is out of bounds, it should notify the user instead.
Recommend a good movie from the collection
◦ This should choose a random movie, check if it is a good movie based on the relevant function, and either print the information to the user or guess again if it was not a good movies If there are no good movies in the collection, tell the user that no good movies exist in the collection.
Hint: You can use a counter variable to keep track of the guesses. When you’ve guessed more times than numbers of elements in the array, you can stop. However, this means you might miss some movies if the same index is randomly selected multiple times. If you want to challenge yourself further, consider another way you could handle that situation.
Quit
◦ Ends the loop and the program
(user input is in bold)Sample Output:
[Laser Disc Collection]
How many movies do you have? 10
Movie 1:
*Enter Title: Back to the Future
*Enter Genre: Science Fiction
*Enter Release Year: 1985
*Enter Rating: 5.0
Movie 2:
*Enter Title: Twin Peaks Season 1
*Enter Genre: Mystery-Horror Serial Drama
*Enter Release Year: 1992
*Enter Rating: 4.5
//Keep going for all 10 movies (THIS IS NOT PART OF THE OUTPUT)
[Main Menu]
1) Movie Info
2) Recommend a Good Movie
3) Log off
Choice: 1
Which Movie do you want? 100
Sorry, that’s not a valid Movie index
[Main Menu]
1) Movie Info
2) Recommend a Good Movie
3) Log off
Choice: 1
Which movie do you want? 0
0. Back to the Future, 1985
Genre: Science-Fiction
Rating: 5.0
[Main Menu]
1) Movie Info
2) Recommend a Good Movie
3) Log off
Choice: 2
You should try: Dune (1984)!
It has a rating of 4.1
[Main Menu]
1) Movie Info
2) Recommend a Good Movie
3) Log off
Choice: 3
Goodbye!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images