public abstract class Company{//抽象父类 private String brand;//品牌 private int id;//车辆编号 private float price;//租赁价格 private String license;//车牌号 private int days;//租赁天数 private double payMoney;//应付租金金额 public Company(){ }//空构造 public int getDays() { return days; } public void setDays(int days) { this.days = days; } public double getPayMoney() { return payMoney; } public void setPayMoney(double payMoney) { this.payMoney = payMoney; } public String getLicense() { return license; } public void setLicense(String license) { this.license = license; } public int getId() { return id; } public void setId(int id) { this.id = id; } public float getPrice() { return price; } public void setPrice(float price) { this.price = price; } public String getBrand() { return brand; } public void setBrand(String brand) { this.brand = brand; } public abstract float RecentFee(int days);//抽象支付计算方法 }
时间: 2024-01-07 16:02:21 浏览: 30
这是一个抽象类 Company,其中包含了一些车辆租赁的基本属性和方法。其中,品牌、编号、价格、车牌号、租赁天数、应付租金金额都是私有属性,可以通过相应的 getter 和 setter 方法进行访问和修改。同时,还有一个抽象的 RecentFee(int days) 方法,用于计算车辆租赁的应付金额,具体实现需要在子类中完成。
相关问题
public class Department { // 属性 private Integer deptId; private String deptName;sql建表语句
以下是一个基本的SQL建表语句示例,用于创建一个名为`departments`的表,包含部门ID和部门名称字段:
```sql
CREATE TABLE departments (
deptId INT PRIMARY KEY,
deptName VARCHAR(50) NOT NULL
);
```
在这个示例中,`deptId`是主键,`deptName`是不可为空的字符串字段。
请根据您的具体需求进行调整和扩展。
帮我完善class Book { private: // 书本ID int id; string title; };
好的,以下是完善后的代码,我添加了构造函数、设置和获取 id、title 的方法:
```
class Book {
private:
int id; // 书本ID
string title;
public:
Book(int id, string title) : id(id), title(title) {}
virtual ~Book() {}
// 设置 id
void setId(int id) {
this->id = id;
}
// 获取 id
int getId() const {
return this->id;
}
// 设置 title
void setTitle(string title) {
this->title = title;
}
// 获取 title
string getTitle() const {
return this->title;
}
};
```
在上面的代码中,我添加了构造函数,用于初始化 id 和 title 成员变量。同时,我添加了设置和获取 id、title 的方法,用于对私有成员变量进行操作。这样,Book 类就能够更加完整地描述一本书的信息。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)