-
Notifications
You must be signed in to change notification settings - Fork 3
MovieRentalStoreWithFeatureEnvy test
Mikhail Pravilov edited this page Jul 3, 2018
·
1 revision
Complex test case (could be complete part of project) with obvious feature envy code smell. It was taken from book named Refactoring: Improving the Design of Existing Code.
Member | Move to |
---|---|
Customer.getMovie(Movie) | Rental |
package movieRentalStoreWithFeatureEnvy;
import java.util.Vector;
class Customer {
private String _name;
private Vector _rentals = new Vector();
public Customer(String name) {
_name = name;
}
public String getMovie(Movie movie) {
Rental rental = new Rental(new Movie("", Movie.NEW_RELEASE), 10);
Movie m = rental._movie;
return movie.getTitle();
}
public void addRental(Rental arg) {
_rentals.addElement(arg);
}
public String getName() {
return _name;
}
}
package movieRentalStoreWithFeatureEnvy;
public class Movie {
public static final int CHILDRENS = 2;
public static final int REGULAR = 0;
public static final int NEW_RELEASE = 1;
private String _title;
private int _priceCode;
public Movie(String title, int priceCode) {
_title = title;
_priceCode = priceCode;
}
public int getPriceCode() {
return _priceCode;
}
public void setPriceCode(int arg) {
_priceCode = arg;
}
public String getTitle (){
return _title;
};
}
package movieRentalStoreWithFeatureEnvy;
class Rental {
public Movie _movie;
private int _daysRented;
public Rental(Movie movie, int daysRented) {
_movie = movie;
_daysRented = daysRented;
}
public int getDaysRented() {
return _daysRented;
}
}