diff --git a/README.md b/README.md new file mode 100644 index 0000000..aedf6ae --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Actividad 4-iic2113 + +### Integrantes + +Nombre | GitHub +-------------- | ------- +Agustin Gomez | agomez4 +Diego Sinay | TheDG +Maria Fernada Sepulveda | mf22 + + +### Code Smells + +1. Switch statements +* Línea 21 `customers.rb` +* Se tiene un switch complejo. +* Solución: Controlar la condición booleana de los case en solo una, en vez de comparar uno por uno, se puede añadir directamente. + +2. Data Class +* Class Rental `rental.rb`, Class Movie `movie.rb*` +* Solo se definen atributos, no contienen comportamiento. +* Solución: Dado que Ruby es un lenguaje orientado a objetos, cada una de sus clases podría tener los métodos para acceder a sus clases y modificar el modelo. + +3. Shotgun Surgey +* Class Rental +* Comportamiento segmentado en varios lados, o en este caso, se le quito el comportamiento y se asigno en otra clase. +* Solución: Darle comportamiento a Rental, y no asignar todo a Costumer. + +4. Long Method +* Linea 14 `customers.rb` : statement +* Statement tiene más de 10 lineas de código. +* Solución: Particionar el comportamiento de `statement`. + +5. Large Class +* Class Customer +* Excesivos metodos--> Statement pertenece a algun otro objecto caja o boleta, al cliente no cliente. +* Solución: Crear una nueva clase que encapsule esta funcionalidad. + + + + + + + + diff --git a/customer.rb b/customer.rb index dbc96b1..5c8f412 100644 --- a/customer.rb +++ b/customer.rb @@ -19,21 +19,28 @@ def statement this_amount = 0 # determine amounts for each line case element.movie.price_code + when Movie::REGULAR this_amount += 2 this_amount += (element.days_rented - 2) * 1.5 if element.days_rented > 2 + return this_amount when Movie::NEW_RELEASE this_amount += element.days_rented * 3 + return this_amount when Movie::CHILDRENS this_amount += 1.5 this_amount += (element.days_rented - 3) * 1.5 if element.days_rented > 3 + return this_amount end + #Arreglo + this_amount+=element.get_price() + # add frequent renter points frequent_renter_points += 1 # add bonus for a two day new release rental - if element.movie.price_code == Movie::NEW_RELEASE && element.days_rented > 1 + if element.movie.price_code == Movie::NEW_RELEASE && element.element.days_rented > 1 frequent_renter_points += 1 end diff --git a/movie.rb b/movie.rb index 86f1a3c..db9350e 100644 --- a/movie.rb +++ b/movie.rb @@ -8,5 +8,5 @@ class Movie def initialize(title, price_code) @title, @price_code = title, price_code - end + end end diff --git a/rental.rb b/rental.rb index e275201..1f731ee 100644 --- a/rental.rb +++ b/rental.rb @@ -5,4 +5,5 @@ class Rental def initialize(movie, days_rented) @movie, @days_rented = movie, days_rented end + end \ No newline at end of file