Question
REFACTORING TO REMOVE CODE SMELLS
You are required to perform refactoring on “Movie-Rental” program (program code of the movie, rental and customer class java files) to improve its quality.
You are encouraged to use refactoring services in IDEs such as Eclipse or IntelliJ.

You are required
1) to add a main() method to test the program;
2) to add a new method to print the statement for a customer in XML format, e.g., John Smith , Independent Day , etc.

Please submit your resulting code and a short Word document explaining the rationales behind your refactoring changes.

Your solution must at least contain:
1. At least 3 method extraction operations
(e.g., printing function in the customer class can be extracted to a printing method)
2. At least 3 creation of 3 new classes
(e.g., combine Rental class with Movie class (to remove data class code smell) count as creating one new class).
(e.g., in regarding to the switch statement from line 33-49 in the customer class, creating a module or class for each movie, and put everything in there for that movie, base price, duration, penalty, etc, suddenly you split it to a subclass)
3. At least 3 moving method operations
(e.g., the functionality of the switch statement in the customer class can be moved to the combined rental and movie class)
4. At least 3 renaming operations
(e.g., the method statement() in the customer class could be better renamed according to its functionality)
5. 1-2 replacements of data types
(e.g., such as the constants value in the customer class)

Those operations must be used to removing code smells in the program.
The final program must be running without error.
Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references.
Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

import java.util.Enumeration;
import java.util.Vector;

public class Customer {

    private String _name;
    private Vector _rentals = new Vector();
   
    public Customer (String name) {
       _name = name;
    }
   
    public void addRental(MovieRental arg) {
       _rentals.addElement(arg);
    }
   
    public String getName() {
       return _name;
    }
   
    public Enumeration getRentals() {
      return _rentals.elements();
    }
   
    public String getStatement() {
       Enumeration rentals = this.getRentals();
       String result = "Rental Record for " + getName() + "\n";
       while (rentals.hasMoreElements()) {
            MovieRental each = (MovieRental) rentals.nextElement();
            // s
This is only a preview of the solution.
Please use the purchase button to see the entire solution.
By purchasing this solution you'll be able to access the following files:
Solution.docx
Movie-Rental.zip
Purchase Solution
$60.00
Google Pay
Amazon
Paypal
Mastercard
Visacard
Discover
Amex
View Available Computer Science Tutors 641 tutors matched
Ionut
(ionut)
Master of Computer Science
Hi! MSc Applied Informatics & Computer Science Engineer. Practical experience in many CS & IT branches.Research work & homework
5/5 (6,803+ sessions)
1 hour avg response
$15-$50 hourly rate
Pranay
(math1983)
Doctor of Philosophy (PhD)
Ph.D. in mathematics and working as an Assistant Professor in University. I can provide help in mathematics, statistics and allied areas.
4.6/5 (6,660+ sessions)
1 hour avg response
$40-$50 hourly rate
Leo
(Leo)
Doctor of Philosophy (PhD)
Hi! I have been a professor in New York and taught in a math department and in an applied math department.
4.9/5 (6,421+ sessions)
2 hours avg response

Similar Homework Solutions