package com.automobile.parts; /** * 方向盘类 - 与汽车是组合关系 * 方向盘是汽车的必要组成部分,不能独立于汽车存在 */ public class SteeringWheel { private String type; private boolean powerAssisted; private double diameter; /** * 构造方法 - 创建方向盘时设置默认属性 */ public SteeringWheel() { this.type = "皮质方向盘"; this.powerAssisted = true; this.diameter = 36.0; // 厘米 } /** * 转向方法 * @param angle 转向角度 */ public void turn(int angle) { System.out.println("方向盘转动 " + angle + " 度"); } /** * 调整方向盘位置 * @param height 高度调整 * @param tilt 倾斜度调整 */ public void adjustPosition(int height, int tilt) { System.out.println("方向盘调整: 高度 " + height + "mm, 倾斜度 " + tilt + "度"); } // Getter 和 Setter 方法 public String getType() { return type; } public void setType(String type) { this.type = type; } public boolean isPowerAssisted() { return powerAssisted; } public void setPowerAssisted(boolean powerAssisted) { this.powerAssisted = powerAssisted; } public double getDiameter() { return diameter; } public void setDiameter(double diameter) { this.diameter = diameter; } }