Task 1
Goal:
- Familiarise with development environment
- Simple class syntax
Task:
Implement a Vehicle class. Every Vehicle is characterised by a current speed (integer) and a maximal speed (integer). A Vehicle has the possibility to store maximum 5 features (string). Besides the necessary constructor(s), setters and getters, a Vehicle has some extra methods:
+ bool changeSpeed(int delta): adds delta to currentspeed if new value is in range [0..maxspeed], returns true if currentspeed has been updated.
+ void addFeature(string): adds string to featurelist if space is still available
+ bool removeFeature(string f): removes feature f from featurelist if f is found, shift content of all following features. Returns true if string has been removed.
+ std::string info() which returns a string like
The vehicle is running at speed [currentspeed]
and has [nr. of features] features:
* [feature1]
* ...
Create a test application which instantiates some vehicles, change speed, add and remove features and show output of info() on different situations to check the implementation
ç®æ :
çæä¸å¼åç¯å¢ã- - - - - -
-ç®åçç±»è¯æ³
ä»»å¡:
å®ç°ä¸ä¸ªè½¦è¾çãæ¯è¾è½¦çç¹ç¹æ¯å½åé度(æ´æ°)åæ大é度(æ´æ°)ãä¸è¾æ±½è½¦æå¯è½å¨åæ大5ç¹å¾(å符串)ãé¤äºå¿ è¦çæé å½æ°(s),çå¼é¢è ågetters,车è¾ä¸äºé¢å¤çæ¹æ³:
changeSpeed + bool(æºåä¸è§æ´²):å¢å currentspeedä¸è§æ´²å¦ææ°å¼æ¯0 . .èå´[ maxspeed],å°è¿åtrue currentspeedæ¯å¦å·²ç»æ´æ°ã
addFeature +æ æ(å符串):å¢å featurelistå符串å¦æ空é´æ¯å¯ä»¥ç
+ bool removeFeature(å符串f):æ¶é¤ç¹å¾ä»featurelistå¦æfæ¯fåç°ãè½®ççå 容,ææçç¹å¾ãå¦æå符串è¿åtrue;å¦æ被移é¤ã
+æ§ç 弦信æ¯(),以å符串çå½¢å¼è¿åå
车è¾è¿è¡é度[currentspeed)
[é£ä¹,ãåè½]çç¹ç¹:
*[feature1]
*â¦
å建ä¸ä¸ªæµè¯çåºç¨ç¨åº,instantiatesä¸äºè½¦è¾,ååé度,æ·»å åå é¤ç¹ç¹åæ¾ç¤ºè¾åºä¿¡æ¯()çä¸åæ åµæ£æ¥æ§è¡æ åµ