S
stephane
I am preparing an exam and I have a copy of last year exam.
I answered the first questions and I wander if I am right or wrong. Can
someone have a look at the questions and at my answers please?
There is no code to write just general questions about the two class'.
the code:
/--
# ifndef CASE_H
# define CASE_H
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std ;
const int Clundi = 1 ;
const int Cmardi = 2 ;
const int Cmercredi = 3 ;
const int Cjeudi = 4 ;
const int Cvendredi = 5 ;
const int Csamedi = 6 ;
const int Cdimanche = 7 ;
class Tcase{
public :
Tcase (int numSemaine, int numJour, double heureDebut, double duree,
char matiere[], char classe[]= " ", char salle[]= " ") ;
int getNumSemaine() const ;
double getDuree() const ;
void printLn() const ;
private :
//attributs obligatoires
int m_numSemaine ; //1..53
int m_numJour ; //1..7
double m_heureDebut ; //13h30 = 13.5
double m_duree ; //2h45 = 2.75
char m_matiere[10] ; //p ex. prog7
//attributs optionnels
char m_classe[10] ; //p. ex. 3IG-EE
char m_salle[10] ; //p. ex A46A
}
#endif
# ifndef HORAIRE_H
# define HORAIRE_H
# include <iostream>
# include <cstring>
using namespace std ;
#include « case.h »
class TenseignantError{} ; // the teacher is not matching
class Toverflow{} ; //capacity overflow
const int CcasesMax = 1000 ;
class Thoraire{
public :
//create a new hours schedule
Thoraire (const char nomEnseignant[]) ;
//add a case in the hours schedule
void ajouteCase (Tcase* caseHor) throw (Toverflow) ;
//calculate the total hours
double chargeHoraire() const ;
//return a sample of the schedule
//return an empty schedule if the number of the week doesn't
exist
Thoraire horaireHebdomadaire (int numSem) const ;
/*
Create a new hours schedule by fusionning both schedule, throw an exception
of class TenseignantError when the schedules don't have the same teacher
(enseignant) name.
Throw an exception of class Toverflow when the fusion create an overflow of
capacity (>CcasesMax)
*/
Thoraire operator+ (const Thoraire & hor) const throw (TenseignantError,
Toverflow) ;
Void printLn() ;
Private :
Char m_nomEnseignant [30] ; // obligatory
Tcase* m_cases[CcasesMax] ;
Int m_nbCases ;
} ;
#endif
The questions:
1) Does the method Thoraire::chargeHoraire() have the right to access the
member m_duree of the class Tcase?
2) Does the method Tcase:
rintLn() have the right to access the member
m_heureDebut of the class Tcase?
3) What are the exceptions that can be thrown by the method Thoraire
Thoraire:
perator+(const Thoraire& hor) ?
4) What are the exceptions that can be thrown by the method double
Thoraire::chargeHoraire()?
5) What's the technical reason that forces the developper of the class
Thoraire to declare an array of Tcase pointers as member of the class
instead of an array of Tcase?
Answers according to me:
1) No because it's trying to access the private part of another class.
2) Yes because the method belongs to the same class.
3) when "enseignant" is not matching and when the name of "enseignant" is
not the same.
4) none ? ( I am not sure of this at all)
5) to avoid creating an object which would be infinite. Because it would be
a recursive creation of the objet. meaning an object created in an object
that crate another object and on and on.
thanks for your help!
I answered the first questions and I wander if I am right or wrong. Can
someone have a look at the questions and at my answers please?
There is no code to write just general questions about the two class'.
the code:
/--
# ifndef CASE_H
# define CASE_H
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std ;
const int Clundi = 1 ;
const int Cmardi = 2 ;
const int Cmercredi = 3 ;
const int Cjeudi = 4 ;
const int Cvendredi = 5 ;
const int Csamedi = 6 ;
const int Cdimanche = 7 ;
class Tcase{
public :
Tcase (int numSemaine, int numJour, double heureDebut, double duree,
char matiere[], char classe[]= " ", char salle[]= " ") ;
int getNumSemaine() const ;
double getDuree() const ;
void printLn() const ;
private :
//attributs obligatoires
int m_numSemaine ; //1..53
int m_numJour ; //1..7
double m_heureDebut ; //13h30 = 13.5
double m_duree ; //2h45 = 2.75
char m_matiere[10] ; //p ex. prog7
//attributs optionnels
char m_classe[10] ; //p. ex. 3IG-EE
char m_salle[10] ; //p. ex A46A
}
#endif
# ifndef HORAIRE_H
# define HORAIRE_H
# include <iostream>
# include <cstring>
using namespace std ;
#include « case.h »
class TenseignantError{} ; // the teacher is not matching
class Toverflow{} ; //capacity overflow
const int CcasesMax = 1000 ;
class Thoraire{
public :
//create a new hours schedule
Thoraire (const char nomEnseignant[]) ;
//add a case in the hours schedule
void ajouteCase (Tcase* caseHor) throw (Toverflow) ;
//calculate the total hours
double chargeHoraire() const ;
//return a sample of the schedule
//return an empty schedule if the number of the week doesn't
exist
Thoraire horaireHebdomadaire (int numSem) const ;
/*
Create a new hours schedule by fusionning both schedule, throw an exception
of class TenseignantError when the schedules don't have the same teacher
(enseignant) name.
Throw an exception of class Toverflow when the fusion create an overflow of
capacity (>CcasesMax)
*/
Thoraire operator+ (const Thoraire & hor) const throw (TenseignantError,
Toverflow) ;
Void printLn() ;
Private :
Char m_nomEnseignant [30] ; // obligatory
Tcase* m_cases[CcasesMax] ;
Int m_nbCases ;
} ;
#endif
The questions:
1) Does the method Thoraire::chargeHoraire() have the right to access the
member m_duree of the class Tcase?
2) Does the method Tcase:
m_heureDebut of the class Tcase?
3) What are the exceptions that can be thrown by the method Thoraire
Thoraire:
4) What are the exceptions that can be thrown by the method double
Thoraire::chargeHoraire()?
5) What's the technical reason that forces the developper of the class
Thoraire to declare an array of Tcase pointers as member of the class
instead of an array of Tcase?
Answers according to me:
1) No because it's trying to access the private part of another class.
2) Yes because the method belongs to the same class.
3) when "enseignant" is not matching and when the name of "enseignant" is
not the same.
4) none ? ( I am not sure of this at all)
5) to avoid creating an object which would be infinite. Because it would be
a recursive creation of the objet. meaning an object created in an object
that crate another object and on and on.
thanks for your help!