Method PrintLn (two classes)// need help

S

stephane

Hi,



I must implement the method printLn of the class Thoraire.



And I've done this, can someone tell me if I am right ?



void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{



m_cases.printLn() ;

}

}

Is it possible to print only the schedule of one teacher at a time ? Thanks
for you time.



/--Here my classes



# 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
 
K

Karl Heinz Buchegger

First of all:
Can you check your newsreader settings? All of your
posts come through terrible formatted.
Hi,

I must implement the method printLn of the class Thoraire.

And I've done this, can someone tell me if I am right ?

Well. What does the compiler say?
void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{

m_cases.printLn() ;


Looking at your class definition I can see ...

class Thoraire
{
public :

[...]

private :
char m_nomEnseignant [30] ; // obligatory
Tcase* m_cases[CcasesMax] ;
int m_nbCases ;
};

that m_cases is an array of pointers. Thus m_cases is a single
pointer. But a pointer doesn't have a method printLn(). But the
object it is pointing to has that function. Thus you probably want:

m_cases->printLn();


I noted something in your posted code. You use 'keywords'
Private, Char, Int
(Note the uppercase first letter!)

Those are *not* the C++ keywords, which are all lower case only.
This makes me think that you somewhere have some
#define Private private
#define Char char
#define Int int
which is definitly *not* a good idea!!!

But then: Given the very bad formatting of your text and source code
it could also be possible that your newsread introduced that nonsense.
Which is just an additional argument to: either check and change the
configuration of your newsread or use a different one, since the one
you use is complete crap.
 
S

stephane

Danke schön Karl,

Sorry about the display:

Is it better like this?

Hi,

I must implement the method printLn of the class Thoraire.

And I've done this, can someone tell me if I am right ?



void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{

m_cases.printLn() ;

}

}

Is it possible to print only the schedule of one teacher at a time ? Thanks
for you time.



/--Here my classes
# 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
Karl Heinz Buchegger said:
First of all:
Can you check your newsreader settings? All of your
posts come through terrible formatted.
Hi,

I must implement the method printLn of the class Thoraire.

And I've done this, can someone tell me if I am right ?

Well. What does the compiler say?
void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{

m_cases.printLn() ;


Looking at your class definition I can see ...

class Thoraire
{
public :

[...]

private :
char m_nomEnseignant [30] ; // obligatory
Tcase* m_cases[CcasesMax] ;
int m_nbCases ;
};

that m_cases is an array of pointers. Thus m_cases is a single
pointer. But a pointer doesn't have a method printLn(). But the
object it is pointing to has that function. Thus you probably want:

m_cases->printLn();


I noted something in your posted code. You use 'keywords'
Private, Char, Int
(Note the uppercase first letter!)

Those are *not* the C++ keywords, which are all lower case only.
This makes me think that you somewhere have some
#define Private private
#define Char char
#define Int int
which is definitly *not* a good idea!!!

But then: Given the very bad formatting of your text and source code
it could also be possible that your newsread introduced that nonsense.
Which is just an additional argument to: either check and change the
configuration of your newsread or use a different one, since the one
you use is complete crap.
 
S

Shezan Baig

LOL!
Danke schön Karl,

Sorry about the display:

Is it better like this?

Hi,

I must implement the method printLn of the class Thoraire.

And I've done this, can someone tell me if I am right ?



void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{

m_cases.printLn() ;

}

}

Is it possible to print only the schedule of one teacher at a time ? Thanks
for you time.



/--Here my classes
# 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
"Karl Heinz Buchegger" <[email protected]> a écrit dans le message de (e-mail address removed)...
First of all:
Can you check your newsreader settings? All of your
posts come through terrible formatted.
Hi,

I must implement the method printLn of the class Thoraire.

And I've done this, can someone tell me if I am right ?

Well. What does the compiler say?
void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{

m_cases.printLn() ;


Looking at your class definition I can see ...

class Thoraire
{
public :

[...]

private :
char m_nomEnseignant [30] ; // obligatory
Tcase* m_cases[CcasesMax] ;
int m_nbCases ;
};

that m_cases is an array of pointers. Thus m_cases is a single
pointer. But a pointer doesn't have a method printLn(). But the
object it is pointing to has that function. Thus you probably want:

m_cases->printLn();


I noted something in your posted code. You use 'keywords'
Private, Char, Int
(Note the uppercase first letter!)

Those are *not* the C++ keywords, which are all lower case only.
This makes me think that you somewhere have some
#define Private private
#define Char char
#define Int int
which is definitly *not* a good idea!!!

But then: Given the very bad formatting of your text and source code
it could also be possible that your newsread introduced that nonsense.
Which is just an additional argument to: either check and change the
configuration of your newsread or use a different one, since the one
you use is complete crap.
 
S

stephane

Well it is not different. Sorry.

stephane said:
Danke schön Karl,

Sorry about the display:

Is it better like this?

Hi,

I must implement the method printLn of the class Thoraire.

And I've done this, can someone tell me if I am right ?



void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{

m_cases.printLn() ;

}

}

Is it possible to print only the schedule of one teacher at a time ?
Thanks for you time.



/--Here my classes
# 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
Karl Heinz Buchegger said:
First of all:
Can you check your newsreader settings? All of your
posts come through terrible formatted.
Hi,

I must implement the method printLn of the class Thoraire.

And I've done this, can someone tell me if I am right ?

Well. What does the compiler say?
void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{

m_cases.printLn() ;


Looking at your class definition I can see ...

class Thoraire
{
public :

[...]

private :
char m_nomEnseignant [30] ; // obligatory
Tcase* m_cases[CcasesMax] ;
int m_nbCases ;
};

that m_cases is an array of pointers. Thus m_cases is a single
pointer. But a pointer doesn't have a method printLn(). But the
object it is pointing to has that function. Thus you probably want:

m_cases->printLn();


I noted something in your posted code. You use 'keywords'
Private, Char, Int
(Note the uppercase first letter!)

Those are *not* the C++ keywords, which are all lower case only.
This makes me think that you somewhere have some
#define Private private
#define Char char
#define Int int
which is definitly *not* a good idea!!!

But then: Given the very bad formatting of your text and source code
it could also be possible that your newsread introduced that nonsense.
Which is just an additional argument to: either check and change the
configuration of your newsread or use a different one, since the one
you use is complete crap.
 
S

stephane

it's not funny

"Shezan Baig" <[email protected]> a écrit dans le message de (e-mail address removed)...
LOL!
Danke schön Karl,

Sorry about the display:

Is it better like this?

Hi,

I must implement the method printLn of the class Thoraire.

And I've done this, can someone tell me if I am right ?



void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{

m_cases.printLn() ;

}

}

Is it possible to print only the schedule of one teacher at a time ? Thanks
for you time.



/--Here my classes
# 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
"Karl Heinz Buchegger" <[email protected]> a écrit dans le message de (e-mail address removed)...
First of all:
Can you check your newsreader settings? All of your
posts come through terrible formatted.
Hi,

I must implement the method printLn of the class Thoraire.

And I've done this, can someone tell me if I am right ?

Well. What does the compiler say?
void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{

m_cases.printLn() ;


Looking at your class definition I can see ...

class Thoraire
{
public :

[...]

private :
char m_nomEnseignant [30] ; // obligatory
Tcase* m_cases[CcasesMax] ;
int m_nbCases ;
};

that m_cases is an array of pointers. Thus m_cases is a single
pointer. But a pointer doesn't have a method printLn(). But the
object it is pointing to has that function. Thus you probably want:

m_cases->printLn();


I noted something in your posted code. You use 'keywords'
Private, Char, Int
(Note the uppercase first letter!)

Those are *not* the C++ keywords, which are all lower case only.
This makes me think that you somewhere have some
#define Private private
#define Char char
#define Int int
which is definitly *not* a good idea!!!

But then: Given the very bad formatting of your text and source code
it could also be possible that your newsread introduced that nonsense.
Which is just an additional argument to: either check and change the
configuration of your newsread or use a different one, since the one
you use is complete crap.
 
K

Karl Heinz Buchegger

stephane said:
Danke schön Karl,

Sorry about the display:

Is it better like this?

A little bit. At least the complete source code is better now.
Hi,

I must implement the method printLn of the class Thoraire.

And I've done this, can someone tell me if I am right ?

I already answered that one, didn't you see it?
void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{

m_cases.printLn() ;

}

}

Is it possible to print only the schedule of one teacher at a time ? Thanks
for you time.


I am not sure what you mean with that question and where you problem
is located.
(Part of my unsureness may be the fact that I don't speak french, so it
is hard to me to guess what your program should do, based on the names
of classes and variables).
 
S

stephane

I understand the names of variables in french don't help you. You helped me
already though. Thanks.

Karl Heinz Buchegger said:
stephane said:
Danke schön Karl,

Sorry about the display:

Is it better like this?

A little bit. At least the complete source code is better now.
Hi,

I must implement the method printLn of the class Thoraire.

And I've done this, can someone tell me if I am right ?

I already answered that one, didn't you see it?
void Thoraire ::printLn()

{

cout<< « Teacher's name : « m_nomEsnseignant<<endl ;

for(int i=0 ; i<m_nbCases ;i++)

{

m_cases.printLn() ;

}

}

Is it possible to print only the schedule of one teacher at a time ?
Thanks
for you time.


I am not sure what you mean with that question and where you problem
is located.
(Part of my unsureness may be the fact that I don't speak french, so it
is hard to me to guess what your program should do, based on the names
of classes and variables).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top