Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Kolo{
- private:
- float promien;
- int kolor;
- public:
- Kolo();
- Kolo(float, int);
- double pole()const;
- void ustawPromien();
- void ustawKolor();
- bool operator==(const Kolo &ko)const;
- };
- Kolo::Kolo(){
- promien = 0;
- kolor = 0;
- }
- Kolo::Kolo(float n, int c){
- promien = n;
- kolor = c;
- }
- double Kolo::pole()const{
- if(promien>0)
- return 3.14*(promien*promien);
- else
- return -1;
- }
- void Kolo::ustawPromien(){
- do{
- cout << "Wprowadz promien kola > 0 : " << endl;
- cin >> promien;
- }while(promien<0);
- }
- void Kolo::ustawKolor(){
- cout << "Wprowadz kolor kola: " << endl;
- cin >> kolor;
- }
- bool Kolo::operator==(const Kolo &ko)const{
- if(ko.kolor == kolor && ko.promien == promien)
- return 1;
- else
- return 0;
- }
- int main(){
- Kolo K1;
- Kolo K2(9.5, 10555);
- K1.ustawPromien();
- K1.ustawKolor();
- cout << "Pole wynosi: " << K1.pole() << endl;
- cout << "Pole wynosi: " << K2.pole() << endl;
- cout << "K1 == K2? " << K1 == K2 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement