644
Le logiciel R
rectangle <- Rectangle(0,0,1,1)
plot(fen^ etre);plot(cercle);plot(rectangle)
6.5- Graphe <-function(x=0,y=0,largeur=2,hauteur=2,log="") {
graphe <- list(objets=list())
class(graphe) <- "Graphe"
graphe
}
6.6- ajout.Graphe <- function(graphe,...) {
graphe$objets <- c(graphe$objets,list(...))
graphe
}
ajout <- function(obj,...) UseMethod("ajout")
plot.Graphe <- function(graphe) {
for(objet in graphe$objets) {
plot(objet)
}
}
graphe <- Graphe()
graphe <- ajout(graphe,Fen^ etre(0,0,2,2),Cercle(0,0,.5),
Rectangle(0,0,1,1))
plot(graphe)
6.7- Graphe <- function(...,x=0,y=0,largeur=2,hauteur=2,log="") {
graphe <- list(objets=list())
class(graphe) <- "Graphe"
graphe <- ajout(graphe,Fen^ etre(x,y,largeur,hauteur,log),...)
graphe
}
graphe <- Graphe(Cercle(),Rectangle())
plot(graphe)
6.8- affiche <- function(obj,...) UseMethod("plot")
graphe <- Graphe(Cercle(),Rectangle())
affiche(graphe)
6.9- `
A vous de jouer !
Le logiciel R
rectangle <- Rectangle(0,0,1,1)
plot(fen^ etre);plot(cercle);plot(rectangle)
6.5- Graphe <-function(x=0,y=0,largeur=2,hauteur=2,log="") {
graphe <- list(objets=list())
class(graphe) <- "Graphe"
graphe
}
6.6- ajout.Graphe <- function(graphe,...) {
graphe$objets <- c(graphe$objets,list(...))
graphe
}
ajout <- function(obj,...) UseMethod("ajout")
plot.Graphe <- function(graphe) {
for(objet in graphe$objets) {
plot(objet)
}
}
graphe <- Graphe()
graphe <- ajout(graphe,Fen^ etre(0,0,2,2),Cercle(0,0,.5),
Rectangle(0,0,1,1))
plot(graphe)
6.7- Graphe <- function(...,x=0,y=0,largeur=2,hauteur=2,log="") {
graphe <- list(objets=list())
class(graphe) <- "Graphe"
graphe <- ajout(graphe,Fen^ etre(x,y,largeur,hauteur,log),...)
graphe
}
graphe <- Graphe(Cercle(),Rectangle())
plot(graphe)
6.8- affiche <- function(obj,...) UseMethod("plot")
graphe <- Graphe(Cercle(),Rectangle())
affiche(graphe)
6.9- `
A vous de jouer !
