第三天课程学习完毕

public class robot
{
    public static void main(String[] args) {
        robot rbt = new robot();
        rbt.ShowAttrib();
  rbt.Temperature+=600;
  rbt.ShowAttrib();
    }


    public robot()
    {
        Status="Explorering...";
        Speed=2;
        Temperature=125;
    }
   
    String Status;
    int Speed;
    float Temperature;
   
    void CheckTemperature()
    {
        if (Temperature>660)
        {
            Status = "Returning Home...";
            Speed=5;
        }       
    }
    void ShowAttrib()
    {
  CheckTemperature();
        System.out.println("Status="+Status+"\u2122");
        System.out.println("Speed="+Speed);
        System.out.println("Temprature="+Temperature);
  System.out.println("F Tem is"+Temperature);
  System.out.println("C Tem is"+ftoc(Temperature));
    }

 public float ftoc(float f)
 {
  f-=32;
  f=f/9;
  f*=5;
  return f;
 }
 public float ctof(float c)
 {
  c=c*9;
  c=c/5;
  c+=32;
  return c;
 }
}

你可能感兴趣的:(学习)