十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
那不是软件做的,而是编程通过代码执行的,这是网站的其中一个功能,程序员把代码在后台都已经提前写好了,界面你点击对应的按钮或者链接就会执行相应的代码功能。
成都创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于网站建设、成都网站制作、石河子网络推广、成都小程序开发、石河子网络营销、石河子企业策划、石河子品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;成都创新互联公司为所有大学生创业者提供石河子建站搭建服务,24小时服务热线:13518219792,官方网址:www.cdcxhl.com
主要语言是用PHP做的哦。当然会有什么JAVA脚本,DOM,还有异步交换啥的,
public class Car {
private int num;//编号
private String name;//型号
private double price;//单价
/**
* 无参构造
*/
public Car(){
super();
}
/**
* 有参构造
* @param num
* @param name
* @param price
*/
public Car(int num, String name, double price) {
super();
this.num = num;
this.name = name;
this.price = price;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String inforShow() {
return "Car [num=" + num + ", name=" + name + ", price=" + price + "]";
}
}
public class PriCar extends Car{
private int PersonNum;//最大载客量
public PriCar(int personNum) {
super();
PersonNum = personNum;
}
public PriCar() {
super();
}
public int getPersonNum() {
return PersonNum;
}
public void setPersonNum(int personNum) {
PersonNum = personNum;
}
@Override
public String inforShow() {
return "PriCar [PersonNum=" + PersonNum + "]";
}
}
public class VanCar extends Car {
private double weight;//最大载重
public VanCar(double weight) {
super();
this.weight = weight;
}
public VanCar() {
super();
}
@Override
public String inforShow() {
return "PriCar [num=" + super.getNum() + ", name=" + super.getName() + ", price=" + super.getPrice() +",weight=" + weight + "]";
}
}
测试类不想写了 应该可以自己写出来了吧
class Car
{
// 车辆属性
private String brand; // 品牌
private double engineDisplacement;// 排气量
private double speed;// 当前速度
private boolean status;// 启动状态
private double maxSpeed;// 最大速度
public double getSpeed () {
return this.speed;
}
public Car(String brand, double engineDisplacement, double maxSpeed) {
this.brand = brand;
this.engineDisplacement = engineDisplacement;
this.maxSpeed = maxSpeed;
// 其他属性也要有初始值,不然执行出错。
this.speed = 0;
this.status = false;
}
/** 启动 */
public void start() {
this.status = true;
printNowStatus ();
}
/** 关闭(熄火) */
public void stop() {
// 只在速度为0时关闭(貌似楼上两位没仔细看题…)
if (this.speed == 0)
{
this.status = false;
}
printNowStatus ();
}
/** 加速 */
public void speedUp() {
// 只在启动时可以加速
if (this.status)
{
this.speed = this.speed + 20;
if (this.speed this.maxSpeed)
{
this.speed = this.maxSpeed;
}
}
printNowStatus ();
}
/** 减速 */
public void slowDown() {
// 只在启动时可以减速
if (this.status)
{
this.speed = this.speed - 10;
if (this.speed 0)
{
this.speed = 0;
}
}
printNowStatus ();
}
/** 状态打印,在每次启动,加减速,关闭时调用 */
private void printNowStatus () {
System.out.println("轿车【" + this.brand + "】现在的启动状态是:" + this.status + "速度是:" + this.speed +"。");
}
}
public class TestCar
{
public static void main(String[] args)
{
Car myCar = new Car ("红旗", 2, 120);
//启动
myCar.start();
// 循环加速到120
while (myCar.getSpeed() 120)
{
myCar.speedUp();
}
//循环减速
while (myCar.getSpeed() 0)
{
myCar.slowDown();
}
//关闭
myCar.stop();
}
}
/* 直接拿文本写的,我用的电脑没装jdk,楼主自己到Java开发环境下调试,应该没什么问题… */
参考程序:
public class Student {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void goHome(Traffic t){
System.out.println("学生:"+this.name);
t.run();
}
public Student(String name) {
this.name = name;
}
}
public abstract class Traffic {
protected double speed;
public void run(){
}
}
public class Bus extends Traffic{
@Override
public void run() {
System.out.println("时速为"+super.speed+"公里每小时的汽车正在嘀嗒嘀嗒的开着.");
}
public Bus(double busSpeed) {
super.speed = busSpeed;
}
}
public class Train extends Traffic {
@Override
public void run() {
System.out.println("时速为"+super.speed+"公里每小时的火车正在况且况且的开着.");
}
public Train(double trainSpeed) {
super.speed = trainSpeed;
}
}
public class AirPlan extends Traffic {
@Override
public void run() {
System.out.println("时速为"+super.speed+"公里每小时的飞机正在吴屋吴屋的开着.");
}
public AirPlan(double airPlanSpeed) {
super.speed = airPlanSpeed;
}
}
public class Test {
public static void main(String[] args) {
Traffic traffic1 = new Bus(40);
Student student = new Student("小明");
student.goHome(traffic1);
Traffic traffic2 = new Train(120);
Student student2 = new Student("小花");
student2.goHome(traffic2);
Traffic traffic3 = new AirPlan(300);
Student student3 = new Student("小红");
student3.goHome(traffic3);
}
}