Question: Question 3 [Refactoring] (34 marks) It is a program to print out a statement of a customer's charges at a video rental store. After user

 Question 3 [Refactoring] (34 marks) It is a program to print

Question 3 [Refactoring] (34 marks) It is a program to print out a statement of a customer's charges at a video rental store. After user enters the selected videos information into the system, the charges is calculated and the videos are given to the customer together with a receipt statement. Identify the code smells in the code snippets provided and refactor the code to solve issues, such as: (i) Data Clump that contain identical groups of variables. E.g. movieName, movieType. (ii) Long method code, which could be grouped or extracted to show its own features. (34 marks) The codes before refactoring are shown below: public class mainApp { public static void main(String[] args) { Customer customerl = new Customer ("Tan"); System.out.println (customerl. statement("Iron Man", "REGULAR", 5)); } public class Customer { private String CustName; public Customer (String name) { CustName = name; } public String statement(String movieName, String movieType, int daysRent) { double totalAmount = 0; double thisAmount = 0; String result = "Rental Record for + CustName + " "; if (movieType.equals IgnoreCase ( "REGULAR")) { thisAmount += 2; if (days Rent > 2) thisAmount += (daysRent - 2) * 1.5; } else if (movieType.equals Ignore Case ("NEW_RELEASE")) { thisAmount += daysRent * 3; } else if (movieType.equalsIgnoreCase ("CHILDREN")) { thisAmount += 1.5; if (days Rent > 3) thisAmount += (daysRent 3) * 1.5; result += "\t" + movieName + "\t" + Stringvalueof(thisAmount) + " "; result += "Amount is " + String.valueOf(thisAmount) + " "; return result; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!