pen.h
来自「C++ Source code from a tutorial」· C头文件 代码 · 共 33 行
H
33 行
#include <string>
enum Color {blue, red, black, clear};
enum PenStyle {ballpoint, felt_tip, fountain_pen};
class Pen {
public:
Color InkColor;
Color ShellColor;
Color CapColor;
PenStyle Style;
float Length;
string Brand;
int InkLevelPercent;
void write_on_paper(string words) {
if (InkLevelPercent <= 0) {
cout << "Oops! Out of ink!" << endl;
}
else {
cout << words << endl;
InkLevelPercent = InkLevelPercent - words.length();
}
}
void break_in_half() {
InkLevelPercent = InkLevelPercent / 2;
Length = Length / 2.0;
}
void run_out_of_ink() {
InkLevelPercent = 0;
}
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?