#include "stdafx.h"
#include <iostream>
#include <exception>
#include <fstream>
#include <time.h>
using namespace std;
class brak_danych : public exception {
const char* what() const throw() {
return "brak danych";
}
};
class blad_pliku : public exception {
const char* what() const throw() {
return "blad pliku";
}
};
class za_malo_obecnosci : public exception {
const char* what() const throw() {
return "ponizej polowy obecnosci";
}
};
class brak_danych_osobowych : public exception {
const char* what() const throw() {
return "brak danych osobowych";
}
};
class Student {
public:
string Dane_osobowe;
int* punkty;
bool* obecnosci;
double OcenaKoncowa;
int ObliczOcene() {
int ile_nieob = 0;
for (int i = 0; i < 10; i++) {
if (obecnosci[i] == 0)ile_nieob++;
}
if (ile_nieob >= 5) {
throw za_malo_obecnosci();
}
else {
cout << "Powyzej polowy obecnosci" << endl;
OcenaKoncowa = punkty[0];
}
}
void Wypisz() {
if (OcenaKoncowa == 0) {
throw brak_danych();
}
else {
cout << "Ocena: " << OcenaKoncowa<<endl;
}
if (Dane_osobowe == "") {
throw brak_danych_osobowych();
}
}
void EksportDoPlikuCSV() {
fstream plik;
plik.open("nazwa_pliku.xlsx", ios::out | ios::in);
if (plik.good() == false) {
throw blad_pliku();
}
else cout << "Uzyskano dostep" << endl;
}
Student::Student() {
}
Student::Student(int i){
OcenaKoncowa = 0;
obecnosci = new bool[10];
for (int i = 0; i < 10; i++) {
obecnosci[i] = rand() % 2;
}
punkty = new int[1];
punkty[0] = rand() % 3 + 3;
Dane_osobowe = "";
}
};
class Grupa {
Student*tablicaStudentow;
Grupa::Grupa(){
tablicaStudentow = new Student[10];
}
};
int main()
{
srand(time(NULL));
Student ja(0);
try { ja.Wypisz(); }
catch (exception& e) {
cerr << "exception caught: " << e.what() << endl;
}
try { ja.EksportDoPlikuCSV(); }
catch (exception& e) {
cerr << "exception caught: " << e.what() << endl;
}
try { ja.ObliczOcene(); }
catch (exception& e) {
cerr << "exception caught: " << e.what() << endl;
}
try { ja.Wypisz(); }
catch (exception& e) {
cerr << "exception caught: " << e.what() << endl;
}
system("pause");
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}