Untitled
unknown
plain_text
a year ago
2.6 kB
12
Indexable
#include <iostream>
class Student {
protected:
int id;
char* name;
char* university;
int avePro;
int aveAdd;
double milga;
public:
static constexpr double PRO_COURSE_AVE = 0.7;
static constexpr double ADD_COURSE_AVE = 0.3;
void milgaFoo(int num) {
milga = num * (PRO_COURSE_AVE * avePro + ADD_COURSE_AVE * aveAdd);
}
friend Student operator*(int factor, const Student& other) {
if ((other.avePro < 100 && other.avePro > 0) || (other.aveAdd < 100 && other.aveAdd > 0)) {
double proInPrecent = other.avePro * (factor / 100.0);
double addInPrecent = other.aveAdd * (factor / 100.0);
if ((other.avePro + proInPrecent) * PRO_COURSE_AVE + ADD_COURSE_AVE * (other.aveAdd + addInPrecent) < 100 &&
(other.avePro + proInPrecent) * PRO_COURSE_AVE + ADD_COURSE_AVE * (other.aveAdd + addInPrecent) > 0) {
double proFinalGrade = other.avePro + proInPrecent;
double addFinalGrade = other.aveAdd + addInPrecent;
return Student(proFinalGrade, addFinalGrade);
}
}
return other;
}
friend Student operator+(int factor, const Student& other) {
if (other.avePro * 0.7 + other.aveAdd * 0.3 < 100 && other.avePro * 0.7 + other.aveAdd * 0.3 > 0) {
if ((other.avePro + factor) * 0.7 + (other.aveAdd + factor) * 0.3 < 100) {
return Student(other.avePro + factor, other.aveAdd + factor);
}
}
return other;
}
};
class Yeshiva : public Student {
private:
int aveGma;
int aveHala;
char* nameYeshiva;
public:
Yeshiva(int aveGma, int aveHala, const char* nameYeshiva, int id, const char* name, const char* university, int avePro, int aveAdd, double milga = 0)
: Student(id, name, university, avePro, aveAdd, milga), aveGma(aveGma), aveHala(aveHala) {
this->nameYeshiva = new char[strlen(nameYeshiva) + 1];
strcpy(this->nameYeshiva, nameYeshiva);
}
~Yeshiva() {
delete[] nameYeshiva;
}
void milgaFoo(int num) {
milga = 1.5 * (num * (PRO_COURSE_AVE * avePro + ADD_COURSE_AVE * aveAdd)) + (num * aveGma) + (num * aveHala) + 770;
}
friend Yeshiva operator*(int factor, const Yeshiva& other) {
Student::operator+(factor, other);
return other;
}
friend Yeshiva operator+(int factor, const Yeshiva& other) {
Student::operator+(factor, other);
return other;
}
};
Editor is loading...
Leave a Comment