OOP

was founded in Australia in 1983 and quickly established itself across New Zealand and other countries of Pacifica. The software program you will develop is to calculate and print a statement of a customer's charges at any of their retail stores. At this stage the program looks simple but this is a representative fragment of a larger system. In the program there are three classes namely Movie, Rental and Customer.
 * Scenario **
 * The **Movie** Class is just a simple data class.
 * The **Rental** class represents a customer renting a movie and
 * The **Customer** class represents the customer of the store.

Study the following UML Class diagram: 

The **Customer** class, like the other classes, has getters and setters; however, it also has the method that produces a statement. The program takes the input values as to which movies a customer rented and for how long. It then calculates the charges, which depend on how long the movie is rented, and identifies the type movie. There are three kinds of movies: regular, children's, and new releases. In addition to calculating charges, the statement also computes frequent renter points, which vary depending on whether the film is a new release. As the first step, you will write the program in C# which is familiar to you. At this stage the program should work fine. (Click here for the Example code). Currently, the //Video Ezy// has some other requirements as following: To be able to accommodate the changing business needs, you will decompose the statement method into smaller pieces to make it easier to write an HTML statement method with much less duplication of code. In the Second step, you will do the following: Here is the updated UML class diagram following the changes you have made: The first part of this problem is the //getCharge// method in **Rental** class. Again it is on the wrong object. It is better to calculate the charge within the **Movie** class. However, the method effectively uses two pieces of data, the length of the rental and the type of the movie. In the third step, you will do the following: Here is the updated UML class diagram following the changes you have made: We have several types of movie that have different ways of answering the same question. This sounds like a job for subclasses. We can have three subclasses of movie, each of which can have its own version of charge. See the following diagram: But it has one slight flaw—it doesn't work. A movie can change its classification during its lifetime. An object cannot change its class during its lifetime. There is a solution, however, the State pattern. <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">With the State pattern the classes look like the following:
 * 1) ** The First Step **
 * 1) ** Decomposing and Redistributing the Statement Method **
 * <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">First they want a statement printed in HTML so that the statement can be Web enabled
 * <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">They want to make changes to the way they classify movies, but they haven't yet decided on the change they are going to make. They have a number of changes in mind. These changes will affect both the way renters are charged for movies and the way that frequent renter points are calculated.
 * <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">It is also possible that the charging rules change from time to time
 * 1) <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">moving the amount calculation into another method - call it //‘getCharge’//
 * 2) <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">extract the Frequent Renter Points and make another method – call it ‘getFrequentRenterPoints’
 * 3) <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">move the methods ‘getCharge’ and ‘//getFrequentRenterPoints//’ to the Rental class because it is now it is clear that these methods are on the wrong object. In most cases a method should be on the object whose data it uses.
 * 4) <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">replace the temporary variables with the methods you have just created
 * 5) <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">replace the temporary variables in statement method again to create two new methods called ‘//getTotalCharge//’ and ‘//getTotalFrequentRenterPoints//’
 * 1) <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">By reusing all of the calculation code, now create public String //htmlStatement//
 * 2) ** Replacing the Conditional Logic on Price Code with Polymorphism **
 * 1) <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">move the //getCharge// method on to **Movie** class and pass in the length of the rental as a parameter, which of course is data from the rental.
 * 2) <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">Similarly move the ‘//getTotalFrequentRenterPoints//’ and pass in the length of the rental as a parameter, which of course is data from the rental.
 * 1) ** At last … Inheritance **
 * 1) <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">Now, add the new classes with an abstract method ‘//getCharge’// on price and concrete methods in the subclasses
 * 2) <span style="color: windowtext; font-family: 'Calibri','sans-serif'; font-size: 15px; line-height: 115%;">Replace Conditional with Polymorphism: this you can do by taking one leg of the case statement at a time and creating an overriding method