package klassid; import java.io.Serializable; public class Takisti implements Serializable{ private static final long serialVersionUID = 1L; double r; double u; public Takisti(double r){this.r=r;} public Takisti(String s){ if(s.startsWith("{r:")){ r=Double.parseDouble(s.substring(3, s.indexOf(","))); u=Double.parseDouble(s.substring(s.indexOf("u:")+2, s.length()-2)); } } void uusPinge(double u){this.u=u;} double kysiPinge(){return u;} double kysiVool(){return u/r;} double kysiVoimsus(){return kysiPinge()*kysiVool();} String tekstina(){return "{r:"+r+", u:"+u+"}";} }