机动车JAVA程序代码 机动车java程序代码查询
Java程序大佬,帮忙填下括号里的代码!!
public class Vehicle {
创新互联长期为千余家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为鲁甸企业提供专业的网站设计制作、网站设计,鲁甸网站改版等技术服务。拥有10余年丰富建站经验和众多成功案例,为您定制开发。
private double speed;
private int power;
public double getSpeed() {
return speed;
}
public void setSpeed(double speed) {
this.speed = speed;
}
// 将参数p的值赋值给成员变量power
public void setPower(int p){
this.power = p;
}
public int getPower() {
return power;
}
//将参数s的值与成员变量speed的和赋值给成员变量speed
public double speedUp(int s) {
return this.speed = s + this.getSpeed();
}
//将成员变量speed与参数d的差赋值给成员变量speed
public double speedDown(int d) {
if(this.getSpeed() d) {
return 0;
}
return this.speed = this.getSpeed() - d;
}
}
public class User {
public static void main(String[] args) {
// 每个对象都会提供一个默认的空构造方法。
Vehicle car1 = new Vehicle();
Vehicle car2 = new Vehicle();
car1.setPower(128);
car2.setPower(76);
System.out.println("car1的功率是:"+car1.getPower( ) );
System.out.println("car2的功率是:"+car2.getPower( ) );
//car1调用speedUp( )方法将自己的speed的值增加80
car1.speedUp(80);
//car2调用speedUp( )方法将自己的speed的值增加100
car2.speedUp(100);
System.out.println("car1的速度是:"+car1.getSpeed( ) );
System.out.println("car2的速度是:"+car2.getSpeed( ) );
car1.speedDown(10);
car2.speedDown(20);
System.out.println("car1目前的速度是:"+car1.getSpeed( ) );
System.out.println("car2目前的速度是:"+car2.getSpeed( ) );
}
}
编写一个java程序,编写机动车类,该类有商标,价格,重量等属性,编写对应属性的get和set方法,
public class MotorCar {
private String trademark; //商标
private double price; //价格
private double weight; //重量
public String getTrademark() {
return trademark;
}
public void setTrademark(String trademark) {
this.trademark = trademark;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
}
用java编写一个程序:由车牌号前2位知道车辆所属地 浙江省的市就行
package demo;
import java.util.Scanner;
public class CarCard {
//浙A 杭州,浙B 宁波,浙C 温州,浙D 绍兴,浙E 湖州,浙F 嘉兴,浙G 金华,浙H 衢州,浙J 台州,浙K 丽水,浙L 舟山
//网上搜的,应该是对的,这个东西应该管你要
public static void main(String[] args) {
System.out.println("请输入车牌号");
Scanner sc = new Scanner(System.in);
String carno = sc.next();
String t = carno.substring(0,2);
checkAddressByCarCard(t);
}
private static void checkAddressByCarCard(String no){
String a[]={"浙A","浙B","浙C","浙D","浙E","浙F","浙G","浙H","浙J","浙K","浙L"};
String b[]={"杭州","宁波","温州","绍兴","湖州","嘉兴","金华","衢州","台州","丽水","舟山"};
int index = 0;
for(int i = 0;i11;i++){
if(no.equalsIgnoreCase(a[i])){
index=i;
System.out.println("车辆所在地为:"+b[i]);
}
}
}
}
//不严谨,但是基本功能实现了
新闻标题:机动车JAVA程序代码 机动车java程序代码查询
当前URL:http://ybzwz.com/article/hioioe.html