SCSJ1023 2017 2018 1 SBT2 Solution PDF

Title SCSJ1023 2017 2018 1 SBT2 Solution
Course Programming Technique III
Institution Universiti Teknologi Malaysia
Pages 2
File Size 56 KB
File Type PDF
Total Downloads 21
Total Views 155

Summary

1: ////////////////////////////////////////////////////////////////////////////////2: // Faculty of Computing, Universiti Teknologi Malaysia 3: // SCSJ1023- Programming Technique II 4: // Semester 1, 2017/ 5: // Skill-based Test 2 6: // November 24, 2017 7: // Solution 8: ///////////////////////////...


Description

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:

//////////////////////////////////////////////////////////////////////////////// // Faculty of Computing, Universiti Teknologi Malaysia // SCSJ1023- Programming Technique II // Semester 1, 2017/2018 // Skill-based Test 2 // November 24, 2017 // Solution //////////////////////////////////////////////////////////////////////////////// // Test run start: start 11:27pm, End: 11:42pm, Duration: 15min , Allocation 15 x #include using namespace std; // 4m. 1m each. class Contact{ private: string phone; public: Contact(string p="" ){phone = p;} string getPhone() const {return phone;} }; // 11:29pm // 4m. 1m each. class Car{ private: string plate; public: Car(string p=""){plate = p;} string getPlate() const {return plate;} };

// class defition: 7 class Customer{ private: string name; Contact contact; Car *car;

// 1m goes to oop concept: composition // 1m goes to oop concept: aggregation

public: Customer(string n="" , string p=""):contact(p){ // 1m name = n; car = NULL; // 1m goes to oop concept: aggregation } void setRentedCar(Car *c){car =c;} // 1m string getName() const {return name ;} // 1m string getPhoneNumber () const {return contact.getPhone();} string getRentedCarPlate() const { if (car) return car->getPlate(); return ""; } }; // 11:32pm

// 1m

// 1m

+ 1m for compositon

+ 1m for aggregation + 1m for condition

61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84:

int main() { Car c1 ("JSQ245" ); // 1m Customer customers[2] = { {"Ahmad Kamal", "015-75769800"}, // array creation: 2m {"Siti Nurdiana Abdullah","014-8889900"} }; customers[0].setRentedCar (&c1); // 1m // 11:37pm // printing the array: 4m. 1m each for (int i=0; i...


Similar Free PDFs