You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.6 KiB
71 lines
1.6 KiB
package com.car.model;
|
|
|
|
/**
|
|
* 电子控制单元类 - 汽车电子系统的组件
|
|
* 与ElectronicSystem类是组合关系
|
|
*/
|
|
public class ElectronicControlUnit {
|
|
private String name; // ECU名称
|
|
private String function; // 功能描述
|
|
private boolean isOperational; // 是否正常工作
|
|
|
|
/**
|
|
* 构造方法
|
|
* @param name ECU名称
|
|
* @param function 功能描述
|
|
*/
|
|
public ElectronicControlUnit(String name, String function) {
|
|
this.name = name;
|
|
this.function = function;
|
|
this.isOperational = true;
|
|
}
|
|
|
|
/**
|
|
* 诊断ECU状态
|
|
* @return 诊断结果
|
|
*/
|
|
public boolean diagnose() {
|
|
// 模拟诊断过程
|
|
return isOperational;
|
|
}
|
|
|
|
/**
|
|
* 重置ECU
|
|
*/
|
|
public void reset() {
|
|
if (!isOperational) {
|
|
isOperational = true;
|
|
System.out.println(name + " ECU has been reset.");
|
|
}
|
|
}
|
|
|
|
// getter and setter methods
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public String getFunction() {
|
|
return function;
|
|
}
|
|
|
|
public void setFunction(String function) {
|
|
this.function = function;
|
|
}
|
|
|
|
public boolean isOperational() {
|
|
return isOperational;
|
|
}
|
|
|
|
public void setOperational(boolean isOperational) {
|
|
this.isOperational = isOperational;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "ElectronicControlUnit [name=" + name + ", function=" + function + ", isOperational=" + isOperational + "]";
|
|
}
|
|
} |