java的自行车举例代码 java 自行车

java跪求大佬解答一道题?class Bicycle{
public String color;
public double weight;
public double trackWidth;
public String model;
public double price;
public Bicycle(String color, String model, double weight, double trackWidth, double price) {
super();
this.color = color;
this.model = model;
this.weight = weight;
this.trackWidth = trackWidth;
this.price = price;
}
public String toString() {
return "色彩:" this.color "; 车重:" this.weight "; 轮距:" this.trackWidth "; 车型:" this.model "; 车价:" this.price;
}
}
public class RacingBike extends Bicycle{
private int varSpeed;
public RacingBike(String color, String model, double weight, double trackWidth, double price,int speed) {
super(color, model, weight, trackWidth, price);
this.varSpeed=speed;
}
public String toString() {
return super.toString() "; 变速:" this.varSpeed;
}
public static void main(String[] args) {
RacingBike rb=new RacingBike("白色","山地自行车",13,1.6,512,8);
System.out.println(rb);
}
}
java编程题 题目在问题补充里 急求答案!class Bicycle {
private String brand;
private String color;
private float price;
public Bicycle() {
}
public Bicycle(String brand, String color, float price) {
this.brand = brand;
this.color = color;
this.price = price;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public void go() {
System.out.println("前进");
}
public void turn() {
System.out.println("拐弯");
}
public void stop() {
System.out.println("停车");
}
public void whistle() {
System.out.println("响铃");
}
}
public class Test {
public static void main(String[] args) {
Bicycle b1 = new Bicycle("凤凰", "红", 11);
b1.go();
b1.turn();
b1.stop();
b1.whistle();
System.out.println();
Bicycle b2 = new Bicycle();
b2.setBrand("永久");
b2.setColor("黄");
b2.setPrice(12);
b2.go();
b2.turn();
b2.stop();
b2.whistle();
}
}
java编程: 创建一个名称为bike的类,在该类中定义一个表示自行车颜色的成员变量color,还定义了一个叫做class bike{
String color="";
String getMes(){
return color;
}
static void main(){
bike b=new bike();
System.out.println(b.getMes());
}
}
JAVA题 急求设计一个交通工具类Vehicle,它具有如下属性:public class Vehicle {
private int speed;
private String kind;
private String color;
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
【java的自行车举例代码 java 自行车】 }
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public Vehicle(){
this.setSpeed(20);
this.setKind("自行车");
this.setColor("红");
}
public static void main(String[] args) {
Vehicle v = new Vehicle();
System.out.println("颜色:" v.getKind() "类型:" v.getKind() "速度:" v.getSpeed());
v.setColor("黄");
v.setKind("汽车");
v.setSpeed(60);
System.out.println("颜色:" v.getKind() "类型:" v.getKind() "速度:" v.getSpeed());
}
}
java的自行车举例代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java 自行车、java的自行车举例代码的信息别忘了在本站进行查找喔 。

    推荐阅读