⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vehicle.java

📁 java(sl275课程习题解module1-module3共7道习题的题目以及程序)
💻 JAVA
字号:
public class Vehicle 
{
   private double load,maxLoad;
   public Vehicle(double maxLoad) 
    {
      this.maxLoad=kiloToNewts(maxLoad);
    }
   public double getLoad() 
    {
      return newtsToKilo(load);
    }
   public double getMaxLoad() 
    {
      return newtsToKilo(this.maxLoad);
    }
   public boolean addBox(double weight) 
    {
       boolean f;
       if (this.load+kiloToNewts(weight)>this.maxLoad)
          f=false;
       else 
        {
          f=true;
          this.load=this.load+kiloToNewts(weight);
        }    
       return f;
     }
  private double newtsToKilo(double weight)
    {
       return (weight*9.8);    
    }
  private double kiloToNewts(double weight)
    {
       return (weight/9.8);
     }
}
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -