ILHAM MUHAMAD WASPADA 21701053026 UAS PBO 1. Buatlah class dan objek untuk sebuah segitiga siku-siku. 2. Buat constructor , destructor dan copy constructor berdasarkan soal no 1. //program class #include<iostream> using namespace std; class segitiga { double sisiA; double sisiB; double sisiC; public: void SetUkuran(double a, double b,double c); //constructor segitiga() { sisiA = 10; sisiB = 11; sisiC = 12; cout<<"construct dari persegi"; cout<<endl; } //destructor ~segitiga() { cout<<"ini adalah Destrcutor dan segitiga dimusnahkan"; cout<<endl; } double luas(); double keliling(); double GetsisiA(); double GetsisiB(); double GetsisiC(); }; int main() { segitiga s; //sgt.SetUkuran(10,11,12);// segitiga stiga = s; cout<<"alas : "<<s.GetsisiA()<<endl; cout<<"tinggi : "<<s.GetsisiB()<<endl; cout<<"sisi : "<<s.GetsisiC()<<endl; cout<<"Luas : "<<s.luas()<<endl; cout<<"keliling : "<<s.keliling()<<endl; return 0; } void segitiga::SetUkuran(double a, double b,double { sisiA = a; sisiB = b; sisiC = c; } double segitiga::keliling() { return sisiA+sisiB+sisiC; } double segitiga::luas() { return 0.5*sisiA*sisiB; } double segitiga::GetsisiA() { return sisiA; } double segitiga::GetsisiB() { return sisiB; } double segitiga::GetsisiC() { return sisiC; } c) HASIL NO 1 & 2 3. Isilah titik-titik di bawah ini agar program encapsulation bisa berjalan ! (isian bebas) #include <iostream> using namespace std; class remoteTV{ private: string tombolNo[10]; public: void setTombolNo(int i, string value){ tombolNo[i] = value; } string getTombolNo(int i){ return tombolNo[i]; } }; int main(){ remoteTV ruangTamu; ruangTamu.setTombolNo(0, "Channel BCPP"); ruangTamu.setTombolNo(1, "Channel BelajarCPP"); ruangTamu.setTombolNo(2, "Channel CPP"); ruangTamu.setTombolNo(3, "Channel C"); cout<<" ...................."<<endl; cout<<"...................."<<endl; cout<<ruangTamu.getTombolNo(0)<<endl; cout<<ruangTamu.getTombolNo(1)<<endl; cout<<ruangTamu.getTombolNo(2)<<endl; cout<<ruangTamu.getTombolNo(3)<<endl; cout<<"...................."<<endl; cout<<"...................."<<endl; return 0; } #include <iostream> using namespace std; class remoteTV{ private: string tombolNo[10]; public: void setTombolNo(int i, string value){ tombolNo[i] = value; } string getTombolNo(int i){ return tombolNo[i]; } }; int main(){ remoteTV ruangTamu; ruangTamu.setTombolNo(0, "Channel BCPP"); ruangTamu.setTombolNo(1, "Channel BelajarCPP"); ruangTamu.setTombolNo(2, "Channel CPP"); ruangTamu.setTombolNo(3, "Channel C"); cout<<" ...................."<<endl; cout<<"...................."<<endl; cout<<ruangTamu.getTombolNo(0)<<endl; cout<<ruangTamu.getTombolNo(1)<<endl; cout<<ruangTamu.getTombolNo(2)<<endl; cout<<ruangTamu.getTombolNo(3)<<endl; cout<<"...................."<<endl; cout<<"...................."<<endl; return 0; } HASIL NO 3