① 1. 编写一个Java应用程序,设计一个汽车类Vehicle,包含的成员属性有:车轮个数wheels和车重weight。
classVehicle{privateintwheels;privatefloatweight;protectedVehicle(intwheels,floatweight){this。wheels=wheels;this。weight=weight。是普通的除号,即10/2=5。
编写java程序的注意事项:
大小写敏感:Java是大小写敏感的,这就意味着标识符Hello与hello是不同的。
类名:对于所有的类来说,类名的首字母应该大写。如果类名由若干单词组成,那么每个单词的首字母应该大写,例如 MyFirstJavaClass。
方法名:所有的方法名都应该以小写字母开头。如果方法名含有若干单词,则后面的每个单词首字母大写,例如myFirstJavaClass。
② Java建立一个汽车(Car)类,包括品牌(String car_brand)、速度(double car_speed)两个成员变量具体看图
这个代码还是比较简单,下面的代码可以参考
classCar{
privateStringcar_brand;
privatedoublecar_speed;
publicCar(){}
publicCar(Stringbrand,doublespeed){
this.car_brand=brand;
this.car_speed=speed;
System.out.println(this.car_brand+"汽车正以时速"
+this.car_speed+"公里的速度行驶");
}
publicvoidspeedUp(Stringbrand){
System.out.println(brand+"汽车正在加速行驶");
}
publicvoidspeedUp(Stringbrand,doublespeed){
System.out.println(brand+"汽车正以时速"
+speed+"公里的速度加速行驶");
}
publicvoidspeedDown(Stringbrand){
System.out.println(brand+"汽车正在减速行驶");
}
publicvoidspeedDown(Stringbrand,doublespeed){
System.out.println(brand+"汽车正以时速"
+speed+"公里的速度减速行驶");
}
}
classTest{
publicstaticvoidmain(String[]args){
Carcar=newCar("宝马",100.5);
car.speedUp("法拉利");
car.speedUp("法拉利",280.5);
car.speedDown("法拉利");
car.speedDown("法拉利",120.9);
}
}
③ Java定义一个汽车类,要求在底下,谢谢各位了
import java.io.Serializable;public class Main {public static void main(String[] args) {System.out.println(setCar(120, true, 1.5, "black"))。
以待语言开发成功后,能有半导体芯片生产商开发和生产这种硬件平台。对于新语言的设计,Sun公司研发人员并没有开发一种全新的语言,而是根据嵌入式软件的要求。
对C++进行了改造,去除了留在C++的一些不太实用及影响安全的成分,并结合嵌入式系统的实时性要求,开发了一种称为Oak的面向对象语言。
由于C++所具有的优势,该项目组的研究人员首先考虑采用C++来编写程序。但对于硬件资源极其匮乏的单片式系统来说,C++程序过于复杂和庞大。另外由于消费电子产品所采用的嵌入式处理器芯片的种类繁杂,如何让编写的程序跨平台运行也是个难题。
为了解决困难,他们首先着眼于语言的开发,假设了一种结构简单、符合嵌入式应用需要的硬件平台体系结构并为其制定了相应的规范,其中就定义了这种硬件平台的二进制机器码指令系统(即后来成为“字节码”的指令系统)。
④ java定义一个汽车类car
你好,很高兴回答你的问题。
题目要求的代码如下:
public class Car{
private String carNumber;
private int speed;
}
如果有帮助到你,请点击采纳。
⑤ 编写java程序:设计一个汽车类
随便给你建了个,代码如下:
package com.ask.test;
public class Car {
//颜色(黑色、白色等)
private String color;
//品牌(奔驰、宝马、东风等)
private String brand;
//类型(越野、普通汽车等)
private String type;
//构造方法
public Car(String color, String brand, String type) {
super();
this.color = color;
this.brand = brand;
this.type = type;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
⑥ 请问如何用Java编写一个汽车类Car
public class Car {
private String color;//颜色
private int door;//车门数量
private float speed;//车速
public Car(){
this.color = "红色";
this.door = 3;
this.speed = 110;
}
public Car(String color, int door, float speed) {
this.color = color;
this.door = door;
this.speed = speed;
}
public void start(){
//汽车启动。输出汽车已启动,并输出汽车的各个属性
System.out.println("汽车已启动,汽车颜色为"+color+",车门数为"+door+",车速为"+speed);
}
public void speedUp(float speed){
//加速
System.out.println("汽车加速到"+speed+"km/h");
}
public void shutDown(float speed){
//减速
System.out.println("汽车减速到"+speed+"km/h");
}
public void brake(){
//刹车
System.out.println("已刹车");
}
}
public class Test {
public static void main(String[] args){
Car car = new Car();
car.start();
car.speedUp(100);
car.shutDown(60);
car.brake();
Car car1 = new Car("白色",4,20.2F);
car1.start();
car1.speedUp(100);
car1.shutDown(60);
car1.brake();
}
}
运行结果