C++????????????
???????????? ???????[ 2015/1/30 11:37:58 ] ????????C++ ????? ????
???????????
????????????·??????????????????????????????????????0.5?????????????0.4???С????????0.3?????????????????????????????????????????????????????
????????????????????ExpressManager????????????£?
????ExpressManager.h
1 #ifndef __EXPRESSMANAGER_H__
2 #define __EXPRESSMANAGER_H__
3
4 #include <memory>
5
6 enum e_CarType
7 {
8 E_CARTYPE_S??
9 E_CARTYPE_M??
10 E_CARTYPE_B??
11 E_CARTYPE_SIZE??
12 };
13
14 struct s_Car
15 {
16 float passCharge;
17 float trip ;
18 enum e_CarType type;
19
20 };
21
22 static float CHARGE_DEF[E_CARTYPE_SIZE]={0.3F??0.4F??0.5F};
23 const int NAME_LEN=16;
24
25 class ExpressManager
26 {
27
28 public:
29
30 explicit ExpressManager(const char* name="Express"):_passCharge(0.0f)??_tempCharge(0.0f)
31 {
32 memcpy( _name??name??NAME_LEN );
33 }
34
35 ~ExpressManager(void){}
36
37 // pass the express manager
38 // @ car the pass car
39 // @ passCharge the charge for passing
40 float Pass( const struct s_Car* car??float passCharge??float& rCharge );
41
42 // show the charge for passing
43 // @ car the pass car
44 float ShowCharge( const struct s_Car* car ) const ;
45
46
47 float ShowTotal( ) const
48 {
49 printf(" Total is:%0.2f
"??_passCharge);
50 return _passCharge;
51 }
52
53 void PassCar();
54
55 void PassTest();
56
57 private:
58
59 // caculate the charge for passing
60 // @ car the parss car
61 // @ return !0 ??succss to get the value; -1 ??bad data
62 inline float Caculate( const struct s_Car* car ) const
63 {
64 return car->trip*CHARGE_DEF[car->type];
65 }
66
67 float _passCharge;
68 float _tempCharge;
69 char _name[NAME_LEN];
70 };
71
72 #endif
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11