commit

parents
package com.bootcamp20_10.carteles;
public class Cartel {
private Forma forma;
private String text;
public Cartel(Forma forma, String text){
this.forma = forma;
this.text = text;
}
public void rellenarForma(){
if(forma.cuadroFixText(this.text)){
if(forma instanceof Rectangulo){
System.out.println("Se a rellenado el cuadrado exitosamente.");
}else{
System.out.println("Se a rellenado el circulo exitosamente.");
}
}else{
System.out.println("No se a podido rellenar la forma, falta espacio");
}
}
}
package com.bootcamp20_10.carteles;
public class Circulo implements Forma{
private float radio;
private String color;
public Circulo(float radio, String color) {
this.radio = radio;
this.color = color;
}
public float getRadio() {
return radio;
}
public void setRadio(float radio) {
this.radio = radio;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
@Override
public boolean cuadroFixText(String text) {
System.out.println("Forma: Circulo\nEspacio: "+this.radio*2+"\nLongitud Texto: "+text.length());
return text.length() <= radio*2;
}
}
package com.bootcamp20_10.carteles;
public interface Forma {
public boolean cuadroFixText(String text);
}
package com.bootcamp20_10.carteles;
public class Main {
public static void main(String[] args){
Forma rectangulo = new Rectangulo(10f, 5f, "Azul");
Forma ciculo = new Circulo(9.2f, "Amarillo");
Cartel cartel1 = new Cartel(rectangulo, "Atencion Escuela");
Cartel cartel2 = new Cartel(ciculo, "Atencion Escuela");
cartel1.rellenarForma();
cartel2.rellenarForma();
}
}
package com.bootcamp20_10.carteles;
public class Rectangulo implements Forma{
private float longitud;
private float ancho;
private String color;
public Rectangulo(float longitud, float ancho, String color){
this.longitud = longitud;
this.ancho = ancho;
this.color = color;
}
@Override
public boolean cuadroFixText(String text) {
System.out.println("Forma: Rectangulo\nEspacio: "+this.longitud+"\nLongitud Texto: "+text.length());
return text.length() <= longitud;
}
public float getLongitud() {
return longitud;
}
public void setLongitud(float longitud) {
this.longitud = longitud;
}
public float getAncho() {
return ancho;
}
public void setAncho(float ancho) {
this.ancho = ancho;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
}
--Consulta todos los clientes que han alquilado pelculas
select distinct c.customer_id, c.first_name, c.last_name
from customer c
right join rental r on r.customer_id = c.customer_id
order by c.customer_id desc;
--Obtenga todos los clientes que hayan vencido la fecha de vencimiento de pago.Muestra tambin por qu pelculas vencen sus pagos.
select distinct f.film_id, c.customer_id, c.first_name, f.title from customer c
right join rental r on r.customer_id = r.customer_id
right join inventory i on i.inventory_id = r.inventory_id
right join film f on f.film_id = i.film_id
where r.return_date < current_date ;
--Cules son las categoras ms alquiladas?
select c.name, count(c.category_id) from category c
join film_category fc ON fc.category_id = c.category_id
join film f on f.film_id = fc.film_id
join inventory i on i.film_id = f.film_id
join rental r on r.inventory_id = i.inventory_id
group by(c.category_id)
order by count(c.category_id) desc;
--Cuales son las categoras ms alquiladas agrupadas por cliente.
select c2.customer_id, c2.first_name, c.name, count(c.category_id) from category c
join film_category fc ON fc.category_id = c.category_id
join film f on f.film_id = fc.film_id
join inventory i on i.film_id = f.film_id
join rental r on r.inventory_id = i.inventory_id
join customer c2 on r.customer_id = c2.customer_id
group by(c2.customer_id , c.category_id)
order by customer_id, count(c.category_id) desc;
--Cual es el lenguaje ms alquilado
select l.language_id, l.name, count(rental_id) from language l
join film f ON f.language_id = l.language_id
join inventory i on i.film_id = f.film_id
join rental r on r.inventory_id = i.inventory_id
group by (l.language_id)
order by count(r.rental_id) desc
limit 1;
--Cul empleados son los mejores. Significa cual empleados se alquila maximo pelculas.
select s.staff_id, s.first_name, count(r.rental_id) from staff s
join rental r on r.staff_id = s.staff_id
group by(s.staff_id)
order by count(r.rental_id) desc;
--Quin es el actor ms famoso. Significa pelculas de cual actor se alquila maximo.
select a.actor_id, a.first_name, a.last_name, count(r.rental_id) from actor a
join film_actor fa on fa.actor_id = a.actor_id
join film f on f.film_id = fa.film_id
join inventory i on i.film_id = f.film_id
join rental r on r.inventory_id = i.inventory_id
group by(a.actor_id)
order by count(r.rental_id) desc
limit 1;
--Quien es el mejor cliente. Significa quien alquila mximo?
select c.customer_id, c.first_name, c.last_name, count(r.rental_id) from customer c
join rental r on r.customer_id = c.customer_id
group by(c.customer_id)
order by count(r.rental_id) desc
limit 1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment