Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Próba dom.cpp : Defines the entry point for the console application.
- //
- #include <stdio.h>
- #include <tchar.h>
- #include <iostream>
- #include <iomanip>
- using namespace std;
- #define pi 3.14
- class okrag
- {
- public:
- int x;
- int y;
- double r;
- okrag();
- okrag(int x0 , int y0, double r0);
- void pole()
- {
- double p = pi * r * r;
- cout << "Pole kola wynosi: ";
- cout << fixed << setprecision(3) << p << endl;
- }
- void obwod()
- {
- double o = 2 * pi * r;
- cout << "Obwod kola wynosi: ";
- cout << fixed << setprecision(3) << o << endl;
- }
- };
- //konstruktor ktory przypisuje domyslne wartości x=0, y=0, r=1
- okrag::okrag()
- {
- x = 0;
- y = 0;
- r = 1.0;
- }
- //konstruktor ktory przypisuje wartości podane pozniej przez uzytkownika
- okrag::okrag(int x0 , int y0, double r0)
- {
- x = x0;
- y = y0;
- r = r0;
- }
- //konstruktor z niepełną liczbą parametrów
- // okrag::okrag(int x, int y);
- void tablica()
- {
- cout << "Podaj rozmiar tablicy: "<< endl;
- int rozmiar;
- cin >> rozmiar;
- int *tab = new int[rozmiar];
- //decyzja ktorego z konstruktorow uzyc
- cout << "Podaj numer konstruktora" << endl;
- cout << "[1] Konstruktor domyslny" << endl;
- cout << "[2] Kontruktor umozliwiający wpisanie uzytkownikowi wlasnych wartosci" << endl;
- int i;
- cin >> i;
- switch(wyb)
- {
- //domyslne
- case 1:
- okrag kolo();
- tab[0]=kolo();
- break;
- //przez uzytkownika
- case 2:
- okrag kolo(x, y, r);
- break;
- case 3:
- //z pliku (poprzez konstruktor możliwiający wpisane dowolnych wartości
- break;
- }
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- int x0;
- int y0;
- double r0;
- cout << "Prosze podac X, Y oraz R kola: " << endl;
- cin >> x0 >> y0 >> r0;
- okrag kolo = okrag(x0, y0, r0);
- kolo.pole();
- kolo.obwod();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement