Skip to content

Instantly share code, notes, and snippets.

@nicopaez
Last active October 10, 2016 14:04
Show Gist options
  • Save nicopaez/397000399d6a4a4dcc3b32d186c54d01 to your computer and use it in GitHub Desktop.
Save nicopaez/397000399d6a4a4dcc3b32d186c54d01 to your computer and use it in GitHub Desktop.
/*
a. Explique brevemente que es un application domain en el contexto de .Net Framework.
b. NUnit vs MSTest. Desarrolle brevemente: pros, contras de cada uno.
c. Mencione los servidores de integración continua con lo que ha trabajado.
d. El siguiente grupo de clases modela un dominio de alquiler de bicicletas.
1. Analice las clases
2. Identifique potenciales problemas con el diseño/código presentado e indique porque considera que son problemas
3. Proponga una solución para cada uno de los puntos identificados
4. Realice un diagrama de clases
5. Realice un diagrama de secuencia del método Customer.amountToPay()
*/
using System.Collections.Generic;
public class Bike
{
private int dailyPrice;
private int price;
public void setDailyPrice(int dailyPrice)
{
this.dailyPrice = dailyPrice;
}
public int getDailyPrice()
{
return dailyPrice;
}
public void setPrice(int price)
{
this.price = price;
}
public int getPrice()
{
return price;
}
}
public class Rental
{
private Bike bike;
private int period;
private bool isDaily;
public Rental(Bike aBike)
{
this.bike = aBike;
}
public bool IsDaily()
{
return isDaily;
}
public Bike getBike()
{
return bike;
}
public void setPeriod(int period)
{
this.period = period;
}
public int getPeriod()
{
return period;
}
public void setIsDaily(bool isDaily)
{
this.isDaily = isDaily;
}
}
public class Customer
{
private List<Rental> rentals;
public Customer()
{
this.rentals = new List<Rental>();
}
public void addRental(Rental rental)
{
this.rentals.Add(rental);
}
public int amountToPay()
{
int result = 0;
foreach(Rental r in this.rentals)
{
if (r.IsDaily())
{
result += r.getBike().getDailyPrice();
}
else
{
result += r.getBike().getPrice() * r.getPeriod();
}
}
return result;
}
}
/* ejemplo de uso 1
Bike aBike = new Bike();
aBike.setPrice(3);
Rental rental = new Rental(aBike);
rental.setPeriod(5);
Customer aCustomer = new Customer();
aCustomer.addRental(rental);
int amount = aCustomer.amountToPay();
// ejemplo de uso 2
Bike aBike = new Bike();
aBike.setDailyPrice(10);
Rental rental = new Rental(aBike);
rental.setIsDaily(true);
Customer aCustomer = new Customer();
aCustomer.addRental(rental);
int amount = aCustomer.amountToPay();
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment