Skip to content

Instantly share code, notes, and snippets.

@Jatapiaro
Created October 9, 2017 23:16
Show Gist options
  • Save Jatapiaro/7c8c76268e3a950ed857c826f64f4919 to your computer and use it in GitHub Desktop.
Save Jatapiaro/7c8c76268e3a950ed857c826f64f4919 to your computer and use it in GitHub Desktop.
ejercicio
public class Circle{
private double radius;
private String color;
public Circle(double radius, String color){
this.radius = radius;
this.color = color;
}
public double getRadius(){ return this.radius; }
public void setRadius(double radius){this.radius = radius;}
public String getColor(){ return this.color; }
public void setRadius(String color){ this.color = color;}
@Override
public String toString(){
return "Circle: { radious: "+this.radius+", color: "+this.color+"}";
}
}
-----------------------------
public class Cylinder{
public Circle base;
public double height;
public Cylinder(Circle base, double height){
this.base = base;
this.height = height;
}
public Circle getBase(){ return this.base; }
public void setBase(Circle circle){this.base = circle;}
public double getHeight(){ return this.height; }
public void setHeight(double height){ this.height = height;}
@Override
public String toString(){
return "Cylinder: { "+this.base+", height: "+this.height+" }";
}
public static void main(String[] args) {
Cylinder c = new Cylinder(
new Circle(3, "Rosa Mexicano"),
10.5);
System.out.println(c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment