Historique des modifications - Message

Message #2789

Sujet: probleme avec la methode cercle, ligne et rectangle


TypeDateAuteurContenu
Création du message03-08-2007 07:22:01simpat
bonjour,

je suis etudiant en genie informatique/ genie logiciel à Laval. je suis encore
debutant sur le c++. je vous en prie j'ai un probleme. j'ai un exercice qui me
casse la tete. il s'agit en fait de deux main deja implementé et qu'il ne faut
pas du tout modifier. tu dois enfait te servir des affichages et du main pour
implementer les fichiers .h et . cpp que tu aura jugé par toi meme
indispensable pour l'affichage.

voici le premier main:



#include "Dessin.h"
#include <iostream>
using namespace std;
main()
{
Dessin bonhomme(20,30);
bonhomme(6 ,25) = 'O';
bonhomme(14,25) = 'O';
bonhomme(10,15) = 'V';
bonhomme(4 ,6 ) = '\\\\';
bonhomme(16,6 ) = '/';
bonhomme(5 ,5 ) = '\\\\';
bonhomme(15,5 ) = '/';
for(int i=6;i<=14;i++) bonhomme(i,5) = '_';
cout << bonhomme;
return 0;
}


on devrai avoir cet affichage:






O O









V








\\ /
\\_________/






voici le deuxieme main:


#include "Graphe.h"

#include <iostream>

using namespace std;

main()
{
Graphe a(50,30);
Dessin &d = a; // Ceci est juste pour vérifier que vous avez
// bel et bien dérivé Graphe de Dessin.
a.cercle(15,15,14,'a');
a.cercle(15,14,12,'b');
a.cercle(15,13,10,'.');
a.cercle(15,12,8,'!');
a.cercle(15,11,5);
a.cercle(15,10,2);

a.rectangle(40,0,49,9);
a.ligne(40,0,49,9);
a.ligne(49,0,40,9);

cout << a;
return 0;
}



on devrai avoir aussi cet affichage:



aaaaaaa
aaa aaa
aa aa
aa bbbbbbb aa
a bbb bbb a
a bb bb a
aa b ....... b aa
a b ... ... b a
a bb .. .. bb a
a bb . !!!!! . bb a
a b . !! !! . b a
a b . ! ! . b a
a bb . ! ! . bb a
a b .. ! ..... ! .. b a
a b . ! .. .. ! . b a
a b . ! . . ! . b a
a b . ! .. .. ! . b a
a b . ! . ... . ! . b a
abb. ! . .. .. . ! .bba
a b..! . . . . !..b a
a b . ! .. .. .. .. ! . b a ..........
abb. ! . ... . ! .bba .. ..
aabb. ! .. .. ! .bbaa . . . .
a b . ! ..... ! . b a . . . .
a b ..!! !!.. b a . .. .
aabb...!!!!!...bbaa . .. .
aabbb.......bbbaa . . . .
aaabbbbbbbaaa . . . .
aaaaaaa .. ..
..........




voici ce que j'ai fais pour le premier main:



*********************************fichier Dessin.h *************************



#include<iostream>

class Dessin {
private:
char * tableau;
unsigned int width, height;

public:
Dessin(unsigned int x, unsigned int y); // taille du dessin
~Dessin();

char& operator() (unsigned int row, unsigned int col); // surcharge de
l'opérateur //() pour faire : //"bonhomme(6 ,25) = 'O';"
char operator() (unsigned int row, unsigned int col) const;


// pour faire "cout << bonhomme;"
friend std::ostream& operator<<(std::ostream &os, const Dessin &dessin);

};








********************************fichier Dessin.cpp***************************




#include<iostream>
#include"Dessin.h"



Dessin::Dessin(unsigned int x, unsigned int y):tableau(NULL), width(x),
height(y)
{
tableau = new char[width*height];
memset(tableau, 0, sizeof(char)*width*height);
}





Dessin::~Dessin()
{

if(tableau)
{
delete [] tableau;
tableau = NULL;
}
}



char& Dessin::operator() (unsigned int row, unsigned int col)
{
return tableau[col*width+row];
}




char Dessin::operator() (unsigned int row, unsigned int col) const
{
return tableau[col*width+row];
}



std::ostream& operator<<(std::ostream &os, const Dessin &dessin)
{
for(unsigned int j=dessin.height-1;j>0;j--)
{
for(unsigned int i=0;i<dessin.width;i++)
os << dessin(i, j);
os << std::endl;
}
os << std::endl;

return os;
}




tout marche bien main le deuxieme main me bloque. il s'agit de l'affichage d'un
cercle dont les parametres sont, les cordonnees du centre, le rayon et le
caractere pour le dessin. pouvez vous m'aider?

merci

Retour

OptionsLiens officielsCaractéristiquesStatistiquesCommunauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1441 sujets
11339 messages
Dernier membre inscrit: Saidov17
127 invités en ligne
membre en ligne: -
RSS Feed