package soojustus; public class Kera implements RuumiKujund{ double r; public Kera(double r){this.r=r;} public Kera(String s){ String[] m=s.split(" "); if(m.length!=2 || !m[0].equals("kera")){ throw new RuntimeException("Vigane sisend"); } r=Double.parseDouble(m[1]); } public double pindala(){ return 4*Math.PI*r*r; } public double ruumala(){ return 4.0/3*Math.PI*r*r*r; } @Override public String toString(){ return "kera "+r; } }