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

📄 exp3_1.java

📁 (1) 程序功能:设计一个用来描述汽车的类
💻 JAVA
字号:
public class EXP3_1 
{
  String ownerName;
   float speed;
   float dirInDegree;
  //定义私有的,非静态的成员变量表示车主姓名、当前的速率和当前方向盘的转向//角度
  public EXP3_1(String ownerName){
   this.ownerName=ownerName;//定义构造方法
  }
  public EXP3_1(String ownerName, float speed, float dirInDegree){
  	this(ownerName);
   	this.speed =speed;//定义构造方法
   this.dirInDegree = dirInDegree;
 }
  public String getOwnerName()
  { return ownerName;
   }
  public float getspeed(float speed)
  { return this.speed=speed;//定义公有方法获得当前的速率
   }
  public float getdirInDegree(float dirInDegree )
  { return this.dirInDegree=dirInDegree;//定义公有方法获得当前方向盘的转向角度
   }
  public float changespeed(float newspeed)
  {   
	  return this.speed=newspeed;//定义公有方法改变当前的车速
   }
  public void stop()
  { speed=0;
   }
}

⌨️ 快捷键说明

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