Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- #include <random>
- #include <time.h>
- using namespace std;
- class foithths{
- private:
- int size_name;
- char *am;
- string name;
- unsigned int sem, pl_math;
- float *pin;
- public:
- //1
- foithths(const char *a, string b){ //1
- int i = strlen (a); //am
- am = new char [i+1]; //am
- strcpy (am, a); //am
- name = b;
- sem = 1;
- pl_math = 0;
- pin = new float [1];
- pin[0] = 0; //για να μη βγαλει σκουπιδια σε περιπτωση εμφανισης του πινασκα
- }
- foithths(const char *a, string b, unsigned int c){ //2
- int i = strlen (a); //am
- am = new char [i+1]; //am
- strcpy (am, a); //am
- name = b;
- sem = c;
- pl_math = 0;
- pin = new float [1];
- pin[0] = 0; //για να μη βγαλει σκουπιδια σε περιπτωση εμφανισης του πινασκα
- }
- foithths(const char *a, string b, unsigned int c, unsigned int d){ //3
- int i;
- i = strlen (a); //am
- am = new char (i+1); //am
- strcpy (am, a); //am
- name = b;
- sem = c;
- pl_math = d;
- if (pl_math=!0){
- pin = new float [pl_math];
- srand((unsigned int)time(NULL));
- float a = 5.0;
- for (int i=0;i<pl_math;i++)
- cout << ((float(rand())/float((RAND_MAX)) * a)+5) << endl;
- }
- }
- foithths(const foithths &x){ //4 copy constractor
- am = x.am;
- name = x.name;
- sem = x.sem;
- pl_math = x.pl_math;
- }
- //2
- void set_am(const char *a){
- delete[]am;
- int i = strlen (a);
- am = new char (i+1);
- strcpy (am, a);
- }
- void set_name(string b){
- name = b;
- }
- void set_sem(unsigned int c){
- sem = c;
- }
- void set_pl_math(unsigned int d){
- pl_math = d;
- }
- void set_pin(float *e){
- /* pin = new float [pl_math];
- for (int i=0; i<pl_math; i++){
- do{
- cin >> pin[i];
- } while (!(pin[i]>=5 & pin[i]<=10));
- }
- if (pl_math=!0){
- pin = new float [pl_math];
- for (int i=0; i<pl_math; i++){
- do{
- pin[i] = e[i];
- } while (!(pin[i]>=5 & pin[i]<=10));
- }
- } */
- if (pl_math=!0){
- pin = new float [pl_math];
- srand((unsigned int)time(NULL));
- float a = 5.0;
- for (int i=0;i<pl_math;i++)
- cout << ((float(rand())/float((RAND_MAX)) * a)+5) << endl;
- }
- }
- char get_am(){
- return *am;
- }
- string get_name(){
- return name;
- }
- unsigned int get_sem(){
- return sem;
- }
- unsigned int get_pl_math(){
- return pl_math;
- }
- float *get_pin(){
- // int j;
- // for (j=0; j<pl_math; j++){
- // cout << pin[j] << endl;
- // }
- return pin;
- }
- //3
- void prosthiki_math(foithths &x){ //να αλλαξω το ωοιδ
- pl_math++;
- float* pin2 = new float [pl_math];
- for (int j=0; j<pl_math-1; j++){
- pin2[j] = pin[j];
- }
- do{
- cin >> pin2[pl_math];
- } while (!(pin2[pl_math]>=5 & pin2[pl_math]<=10));
- delete(pin);
- pin = new float [pl_math];
- for (int i=0; i<pl_math; i++){
- do{
- pin[i] = pin2[i];
- } while (!(pin[i]>=5 & pin[i]<=10));
- }
- }
- // ~foithths();
- };
- /* float readp(unsigned int pl_m){
- float *p = new float [pl_m];
- for (int i=0; i<pl_m; i++){
- do{
- cin >> p[i];
- }while (!(p[i]>=5 && p[i]<=10));
- }
- return *p;
- }*/
- int main(void){
- // foithths x1("1" , "A" );
- // foithths x2("2" , "B" , 2);
- unsigned int d = 2;
- foithths x3("345" , "Cat" , 3, 1);
- // foithths x4(x3);
- // cout << x3.get_am() <<endl;
- // cout << x3.get_name() <<endl;
- // cout << x3.get_sem() <<endl;
- // cout << x3.get_pl_math() <<endl;
- cout << x3.get_pin() <<endl;
- cout << endl;
- /* x2.get_am();
- x2.get_name();
- x2.get_sem();
- x2.get_pl_math();
- x2.get_pin();
- cout << endl;
- x3.get_am();
- x3.get_name();
- x3.get_sem();
- x3.get_pl_math();
- x3.get_pin();
- x3.set_am("000");
- x3.set_name("AAA");
- x3.set_sem(9);
- x3.set_pl_math(2);
- x3.set_pin();
- x3.get_am();
- x3.get_name();
- x3.get_sem();
- x3.get_pl_math();
- x3.get_pin();
- cout << endl;*/
- }
- //TO DO
- //SETTER am EMFANIZEI MONO TO 1 GRAMMA, ΕΡΩΤΗΜΑ 3 ΑΛΛΑΖΩ ΤΟ VOID ΚΑΙ ΒΛΕΠΩ ΑΝ ΔΟΥΛΕΥΕΙ
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement