
简介:汽车类的设计
汽车的抽象描述
汽车类的特征和功能——分析抽象汽车个体的特征和功能
- 特征:型号、颜色、价格、出厂日期、载客量、载重量……
- 功能:运动、鸣笛、倒车、播放音乐、恒温、定位……
汽车类的定义
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#include <cstring> #include <mmsystem.h> #include <windows.h> using namespace std; class { private: char type[20]; char color[20]; float price; int carry_weight; int carry_customer; public: void set_data(char *t, char *c, float pri, int cw, int cc); void movecar(int l, int k); void horming(int num); void downcar(int l); void play_mp3(char *ps); char *show_type() { return type; } }; void automobile::set_data(char *t, char *c, float pri, int cw, int cc) { strcpy(type, t); strcpy(color, c); price = pri; carry_weight = cw; carry_customer = cc; } void automobile::movecar(int l, int k) { cout << "n" << type << "水平直线运动:" << endl; for (int i = 0; i < l; i++) { cout << ' ' << "o_o"; Sleep(1000 / k); cout << "bbb"; } } void automobile::downcar(int l) { cout << "n" << type << "垂直下降运动:" << endl; for (int i = 0; i < l; i++) { cout << "o_o"; Sleep(500); cout << "bbb" << " "; cout << endl; } } void automobile::horming(int num) { for (int i = 0; i < num; i++) { cout << type; cout << '
|
近期评论