Advertisement
Guest User

Untitled

a guest
Mar 12th, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.95 KB | None | 0 0
  1. // Próba dom.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include <stdio.h>
  5. #include <tchar.h>
  6. #include <iostream>
  7. #include <iomanip>
  8. using namespace std;
  9. #define pi 3.14
  10.  
  11.  
  12. class okrag
  13. {
  14.     public:
  15.         int x;
  16.         int y;
  17.         double r;
  18.  
  19.        
  20.  
  21.     okrag();
  22.     okrag(int x0 , int y0, double r0);
  23.    
  24.     void pole()
  25.         {
  26.             double p = pi * r * r;
  27.             cout << "Pole kola wynosi: ";
  28.             cout << fixed << setprecision(3) << p << endl;
  29.         }
  30.  
  31.     void obwod()
  32.         {
  33.             double o = 2 * pi * r;
  34.             cout << "Obwod kola wynosi: ";
  35.             cout << fixed << setprecision(3) << o << endl;
  36.         }
  37.    
  38.  
  39. };
  40.  
  41.    
  42. //konstruktor ktory przypisuje domyslne wartości x=0, y=0, r=1
  43.     okrag::okrag()
  44.         {
  45.             x = 0;
  46.             y = 0;
  47.             r = 1.0;
  48.         }
  49.  
  50. //konstruktor ktory przypisuje wartości podane pozniej przez uzytkownika
  51.     okrag::okrag(int x0 , int y0, double r0)
  52.         {
  53.             x = x0;
  54.             y = y0;
  55.             r = r0;
  56.         }
  57.  
  58. //konstruktor z niepełną liczbą parametrów
  59. //  okrag::okrag(int x, int y);
  60.  
  61.  
  62.  
  63.     void tablica()
  64.         {
  65.             cout << "Podaj rozmiar tablicy: "<< endl;
  66.             int rozmiar;
  67.             cin >> rozmiar;
  68.             int *tab = new int[rozmiar];
  69.             //decyzja ktorego z konstruktorow uzyc
  70.  
  71.             cout << "Podaj numer konstruktora" << endl;
  72.             cout << "[1] Konstruktor domyslny" << endl;
  73.             cout << "[2] Kontruktor umozliwiający wpisanie uzytkownikowi wlasnych wartosci" << endl;
  74.  
  75.             int i;
  76.             cin >> i;
  77.            
  78.             switch(wyb)
  79.                 {
  80.                     //domyslne
  81.                     case 1:
  82.                     okrag kolo();      
  83.                     tab[0]=kolo();
  84.                     break;
  85.  
  86.                    
  87.                     //przez uzytkownika
  88.                     case 2:
  89.                     okrag kolo(x, y, r);
  90.                     break;
  91.  
  92.  
  93.                     case 3:
  94.                     //z pliku (poprzez konstruktor możliwiający wpisane dowolnych wartości
  95.  
  96.                     break;
  97.                 }
  98.         }
  99.  
  100.  
  101.  
  102.  
  103. int _tmain(int argc, _TCHAR* argv[])
  104. {
  105.     int x0;
  106.     int y0;
  107.     double r0;
  108.  
  109.     cout << "Prosze podac X, Y oraz R kola: " << endl;
  110.     cin >> x0 >> y0 >> r0;
  111.  
  112.     okrag kolo = okrag(x0, y0, r0);
  113.  
  114.     kolo.pole();
  115.     kolo.obwod();
  116.  
  117.  
  118.  
  119.     system("pause");
  120.     return 0;
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement