Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <vector>
- using namespace std;
- class Uczen{
- public:
- string imie;
- char nazwisko[20];
- long pesel;
- void ustawImie(){
- cout << "Imie: "; cin >> this->imie;
- }
- void ustawNazwisko(){
- cout << "Nazwisko: "; cin >> this->nazwisko;
- }
- void ustawPesel(){
- cout << "Pesel: "; cin >> this->pesel;
- }
- };
- class UczenSzkoly : public Uczen{
- public:
- string nazwaSzkoly;
- void ustawSzkole(){
- cout << "Nazwa szkoly: "; cin >> this->nazwaSzkoly;
- }
- };
- //Niedokonczone//
- class Figure{
- //Metoda do definiowania najwiekszego obwodu
- };
- class Triangle : Figure{
- };
- class Circle : Figure{
- };
- class Figures{
- //Klasa ma przechowywac wiele obiektow klasy Figure
- //Szukac figury z najwiekszym obwodem
- };
- //-------//
- class Przedmiot{
- private:
- double * oceny;
- int nr_indeksu;
- int liczba_ocen;
- int limit;
- public:
- Przedmiot(int nr_ind, int lim){
- this->nr_indeksu = nr_ind;
- this->limit = lim;
- this->oceny = new double[this->limit];
- this->liczba_ocen = 0;
- for(int i = 0; i < this->limit; i++){
- this->oceny[i] = 0;
- }
- }
- ~Przedmiot(){
- delete [] oceny;
- }
- double obliczSrednia(){
- double suma = 0;
- this->liczba_ocen = 0;
- for(int i = 0; i < this->limit; i++){
- if(this->oceny[i] != 0){
- suma += this->oceny[i];
- this->liczba_ocen++;
- }
- }
- return (suma/this->liczba_ocen);
- }
- bool zaliczenie(){
- if(this->obliczSrednia() > 3) return true;
- else return false;
- }
- void dodajOcene(double ocena){
- this->oceny[this->liczba_ocen] = ocena;
- this->liczba_ocen++;
- }
- void zmienOcene(int indeks, double nowaOcena){
- this->oceny[indeks] = nowaOcena;
- }
- void wypisz(){
- cout << "Nr indeksu: " << this->nr_indeksu << endl;
- cout << "Srednia: " << this->obliczSrednia() << ", zaliczenie: " << this->zaliczenie() << endl;
- cout << "Oceny: ";
- for(int i = 0; i < this->limit; i++){
- if(this->oceny[i] != 0){
- cout << this->oceny[i] << ", ";
- }
- }
- }
- };
- int Zad4(string cluster){
- char x[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R'};
- string modul = cluster.substr(cluster.length()-1, cluster.length());
- int dl = sizeof(x)/sizeof(x[0]);
- int wynik = -1;
- for(int i = 0; i < dl; i++){
- if(modul[0] == x[i]) wynik = i;
- }
- return wynik;
- }
- //Prototypy
- void WyborZadania();
- int main() {
- WyborZadania();
- return EXIT_SUCCESS;
- }
- void WyborZadania(){
- int zad;
- cout << "Wybierz zadanie: ";
- cin >> zad;
- switch(zad){
- case 1:
- {
- UczenSzkoly osoba;
- osoba.ustawImie();
- osoba.ustawNazwisko();
- osoba.ustawPesel();
- osoba.ustawSzkole();
- break;
- }
- case 2:
- {
- cout << "Nie chce mi sie";
- break;
- }
- case 3:
- {
- Przedmiot inf(1122, 20);
- inf.dodajOcene(5);
- inf.dodajOcene(3);
- inf.dodajOcene(2);
- inf.zmienOcene(0,2);
- inf.wypisz();
- break;
- }
- case 4:
- {
- cout << Zad4("Cluster_M");
- break;
- }
- default:
- {
- WyborZadania();
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement