Skip to content
Snippets Groups Projects
Commit 51dacdeb authored by VILLAUME Lucas's avatar VILLAUME Lucas
Browse files

Ajout de la fct toJSON()

parent 9f65d59b
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,13 @@ class Cellule extends Component{ ...@@ -11,6 +11,13 @@ class Cellule extends Component{
setExpression(expression){ setExpression(expression){
this.#expression = expression; this.#expression = expression;
} }
toJSON(){
return {
numero: this.#numero,
expression: this.#expression.toJSON() //voir si on garde expression ou si on met le type d'expression (ex nombre: 12)
}
}
} }
module.exports = Cellule; module.exports = Cellule;
\ No newline at end of file
...@@ -4,4 +4,8 @@ class Component{ ...@@ -4,4 +4,8 @@ class Component{
constructor(name = ''){ constructor(name = ''){
this.#nom = name; this.#nom = name;
} }
getNom(){
return this.#nom;
}
} }
\ No newline at end of file
...@@ -41,6 +41,29 @@ class Document extends Component{ ...@@ -41,6 +41,29 @@ class Document extends Component{
this.#dateModification = date; this.#dateModification = date;
} }
get nom(){
return super.getNom();
}
get auteur(){
return this.#auteur;
}
toJSON(){
let feuillesJSON = [];
feuilles.forEach(feuille => feuillesJSON.push(feuille.toJSON()));
return {
id: this.#id,
nom: super.getNom(),
auteur: this.#auteur,
feuilles: feuillesJSON,
dateCreation: this.#dateCreation,
dateModification: this.#dateModification
}
}
} }
module.exports = Document; module.exports = Document;
\ No newline at end of file
...@@ -16,4 +16,8 @@ class Expression{ ...@@ -16,4 +16,8 @@ class Expression{
isTexte(){ isTexte(){
return false; return false;
} }
toJSON(){
return this.#contenu;
}
} }
\ No newline at end of file
...@@ -21,6 +21,17 @@ class Feuille extends Component{ ...@@ -21,6 +21,17 @@ class Feuille extends Component{
clearCells(){ clearCells(){
this.#cells = [[]]; this.#cells = [[]];
} }
toJSON(){
let cellsJSON = [];
cells.forEach(cell => cellsJSON.push(cell.toJSON()));
return {
nom: super.getNom(),
cells: cellsJSON
}
}
} }
module.exports = Feuille; module.exports = Feuille;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment