Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <vector>
- using namespace std;
- class samochod{
- public:
- int moc;
- int predkosc;
- int cena;
- void pobierzDane(){
- cout << "Moc: "; cin >> this->moc;
- cout << "Predkosc: "; cin >> this->predkosc;
- cout << "Cena: "; cin >> this->cena;
- }
- void wyswietlDane(){
- cout << "Moc: " << this->moc << endl;
- cout << "Predkosc: " << this->predkosc << endl;
- cout << "Cena: " << this->cena << endl;
- }
- };
- class uczen{
- public:
- string imie;
- string nazwisko;
- string klasa;
- string ocena;
- void pobierzDane(){
- cout << "Imie: "; cin >> this->imie;
- cout << "Nazwisko: "; cin >> this->nazwisko;
- cout << "Klasa: "; cin >> this->klasa;
- cout << "Ocena: "; cin >> this->ocena;
- }
- void wyswietlDane(){
- cout << "Imie: " << this->imie << endl;
- cout << "Nazwisko: " << this->nazwisko << endl;
- cout << "Klasa: " << this->klasa << endl;
- cout << "Ocena: " << this->ocena << endl;
- }
- };
- class prostopadloscian{
- private:
- double a, b, h;
- public:
- prostopadloscian(double a, double b, double h){
- this->a = a;
- this->b = b;
- this->h = h;
- }
- int obliczPole(){
- return this->a * this->b * this->h;
- }
- };
- class Rachunek{
- private:
- string data;
- double wartosc_netto;
- double wartosc_brutto;
- double podatek;
- public:
- Rachunek(){
- this->wczytajDane();
- }
- void wczytajDane(){
- cout << "Data :"; cin >> this->data;
- cout << "Wartosc_netto: "; cin >> this->wartosc_netto;
- }
- void wyliczPodatek(){
- this->wartosc_brutto = this->wartosc_netto * 1.23;
- this->podatek = this->wartosc_brutto - this->wartosc_netto;
- }
- void wyswietl(){
- cout << "Data: " << this->data << endl;
- cout << "Wartosc netto: " << this->wartosc_netto << endl;
- cout << "Wartosc brutto: " << this->wartosc_brutto << endl;
- cout << "Podatek: " << this->podatek << endl;
- }
- };
- class MyWater{
- private:
- int large, medium, small;
- static double l,m,s;
- public:
- void addLarge(int num){
- this->large += num;
- }
- void addMedium(int num){
- this->medium += num;
- }
- void addSmall(int num){
- this->small += num;
- }
- void set_l(double x){
- this->l = x;
- }
- void set_m(double x){
- this->m = x;
- }
- void set_s(double x){
- this->s = x;
- }
- void wyswietlDane(){
- double suma = (this->large * this->l) + (this->medium * this->m) + (this->small * this->s);
- cout << "Mam teraz " << suma << " litrow wody" << endl;
- cout << "Duzych butelek: " << this->large << endl;
- cout << "Srednich butelek: " << this->medium << endl;
- cout << "Malych butelek: " << this->small << endl;
- }
- };
- double MyWater::l = 2;
- double MyWater::m = 1;
- double MyWater::s = 0.5;
- class osoba{
- private:
- string imie;
- string nazwisko;
- string adres;
- string gg;
- string email;
- public:
- osoba(string imie, string nazwisko, string adres, string gg, string email){
- this->imie = imie;
- this->nazwisko = nazwisko;
- this->adres = adres;
- this->gg = gg;
- this->email = email;
- }
- osoba(){
- this->ustawDane();
- }
- void wyswietlDane(){
- cout << "-------" << endl;
- cout << "Imie: " << this->imie << endl;
- cout << "Nazwisko: " << this->nazwisko << endl;
- cout << "Adres: " << this->adres << endl;
- cout << "GG (opcjonalne): " << this->gg << endl;
- cout << "Email (opcjonalne): " << this->email << endl;
- cout << "-------" << endl;
- }
- void wyswietlDaneSkrotowo(){
- cout << this->imie << ", " << this->nazwisko << ", " << this->adres << endl;
- }
- void ustawDane(){
- cout << "Imie: "; cin >> this->imie;
- cout << "Nazwisko: "; cin >> this->nazwisko;
- cout << "Adres: "; cin >> this->adres;
- cout << "GG (opcjonalne): "; cin >> this->gg;
- cout << "Email (opcjonalne): "; cin >> this->email;
- }
- };
- class KsiazkaAdresowa{
- private:
- vector < osoba > listaOsob;
- public:
- void dodajNowaOsobe(){
- osoba czlowiek;
- listaOsob.push_back(czlowiek);
- }
- void wyswietlWszystkich(){
- for(int i = 0; i < listaOsob.size(); i++){
- cout << "UID: " << i+1 << ":" << endl;
- listaOsob[i].wyswietlDane();
- }
- }
- void wyswietlWszystkichSkrotowo(){
- for(int i = 0; i < listaOsob.size(); i++){
- cout << "UID: " << i+1 << ": ";
- listaOsob[i].wyswietlDaneSkrotowo();
- }
- }
- void menu(){
- int x;
- cout << "> Wybierz opcje: " << endl;
- cout << ">> 1 - Dodaj nowa osobe " << endl;
- cout << ">> 2 - Edytuj/Usun osobe " << endl;
- cout << ">> 3 - Wyszukaj osoby " << endl;
- cout << ">> 4 - Wyswietl wszystkie osoby " << endl;
- cout << ">> 5 - Import z pliku " << endl;
- cout << ">> 6 - Eksport do pliku " << endl;
- cout << ">> 7 - Wyjscie " << endl;
- cout << "->"; cin >> x;
- switch(x){
- case 1:
- {
- this->dodajNowaOsobe();
- this->menu();
- break;
- }
- case 2:
- {
- int x, uid;
- this->wyswietlWszystkichSkrotowo();
- cout << "Wprowadz uid: "; cin >> uid;
- cout << "1 - usun" << endl << "2 - modyfikuj";
- cin >> x;
- if(x==1){
- string y;
- cout << "Jestes pewny? T/N"; cin >> y;
- if(y=="T") {
- listaOsob.erase(listaOsob.begin()+(uid-1));
- cout << "!!!Pomyslnie usunieto osobe z ksiazki" << endl;
- }
- }
- else if(x==2) listaOsob[uid-1].ustawDane();
- this->menu();
- break;
- }
- case 3:
- {
- this->menu();
- break;
- }
- case 4:
- {
- this->wyswietlWszystkich();
- this->menu();
- break;
- }
- case 7:
- {
- break;
- }
- default:
- {
- this->menu();
- }
- }
- }
- KsiazkaAdresowa(){
- this->menu();
- }
- };
- //Prototypy
- void WyborZadania();
- int main() {
- WyborZadania();
- return EXIT_SUCCESS;
- }
- void WyborZadania(){
- int zad;
- cout << "Wybierz zadanie: ";
- cin >> zad;
- switch(zad){
- case 1:
- {
- samochod x;
- x.pobierzDane();
- x.wyswietlDane();
- break;
- }
- case 2:
- {
- uczen y;
- y.pobierzDane();
- y.wyswietlDane();
- break;
- }
- case 3:
- {
- prostopadloscian box(2,3,4);
- cout << "Pole prostopadloscianu: " << box.obliczPole();
- break;
- }
- case 4:
- {
- Rachunek z;
- z.wyliczPodatek();
- z.wyswietl();
- break;
- }
- case 5:
- {
- MyWater q;
- q.addLarge(5);
- q.addMedium(4);
- q.addSmall(2);
- q.wyswietlDane();
- q.set_l(5);
- q.wyswietlDane();
- break;
- }
- case 6:
- {
- KsiazkaAdresowa facebook;
- }
- default:
- {
- WyborZadania();
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement