parent
3b9d8f7d4d
commit
1943236395
@ -0,0 +1,11 @@
|
|||||||
|
enum Color {
|
||||||
|
BLANC,
|
||||||
|
NOIR,
|
||||||
|
JAUNE,
|
||||||
|
ROUGE,
|
||||||
|
BLEU,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Color
|
||||||
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
import AgeIndice from "../Indices/AgeIndice";
|
||||||
|
import Indice from "../Indices/Indice";
|
||||||
|
import IndiceTester from "../IndiceTester/IndiceTester";
|
||||||
|
import IndiceTesterAge from "../IndiceTester/IndiceTesterAge";
|
||||||
|
|
||||||
|
class IndiceTesterFactory{
|
||||||
|
|
||||||
|
static Create(indice: Indice): IndiceTester{
|
||||||
|
if (indice instanceof AgeIndice){
|
||||||
|
return new IndiceTesterAge(indice)
|
||||||
|
}
|
||||||
|
throw new Error("Method not finished.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IndiceTesterFactory
|
@ -0,0 +1,10 @@
|
|||||||
|
import Indice from "../Indices/Indice"
|
||||||
|
import Person from "../Person"
|
||||||
|
|
||||||
|
interface IndiceTester{
|
||||||
|
|
||||||
|
Works(person: Person): boolean
|
||||||
|
TestWorks(person: Person): boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IndiceTester
|
@ -0,0 +1,22 @@
|
|||||||
|
import AgeIndice from "../Indices/AgeIndice";
|
||||||
|
import Person from "../Person";
|
||||||
|
import IndiceTester from "./IndiceTester";
|
||||||
|
|
||||||
|
class IndiceTesterAge implements IndiceTester{
|
||||||
|
|
||||||
|
private ageIndice: AgeIndice
|
||||||
|
|
||||||
|
constructor(ageIndice: AgeIndice){
|
||||||
|
this.ageIndice = ageIndice;
|
||||||
|
}
|
||||||
|
|
||||||
|
Works(person: Person): boolean {
|
||||||
|
return person.getAge() >= this.ageIndice.getMinimum() && person.getAge()<this.ageIndice.getMaximum()
|
||||||
|
}
|
||||||
|
|
||||||
|
TestWorks(person: Person): boolean {
|
||||||
|
return person.getAge() >= this.ageIndice.getMinimum() && person.getAge()<this.ageIndice.getMaximum()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IndiceTesterAge
|
@ -0,0 +1,28 @@
|
|||||||
|
import Indice from "./Indice";
|
||||||
|
|
||||||
|
class AgeIndice extends Indice {
|
||||||
|
private maximum: number;
|
||||||
|
private minimum: number;
|
||||||
|
|
||||||
|
constructor(id: number, minimum: number, maximum: number) {
|
||||||
|
super(id);
|
||||||
|
this.minimum = minimum;
|
||||||
|
this.maximum = maximum;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implémentation de la méthode abstraite
|
||||||
|
ToString(): string {
|
||||||
|
return "La personne a entre " + this.minimum + " et " + this.maximum + " ans"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getMinimum(): number{
|
||||||
|
return this.minimum
|
||||||
|
}
|
||||||
|
|
||||||
|
getMaximum(): number{
|
||||||
|
return this.minimum
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AgeIndice
|
@ -0,0 +1,10 @@
|
|||||||
|
import Indice from "./Indice";
|
||||||
|
|
||||||
|
abstract class EdgesIndice extends Indice {
|
||||||
|
|
||||||
|
constructor(id: number) {
|
||||||
|
super(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default EdgesIndice
|
@ -0,0 +1,21 @@
|
|||||||
|
abstract class Indice {
|
||||||
|
protected id: number;
|
||||||
|
|
||||||
|
constructor(id: number) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter and setter for id
|
||||||
|
getId(): number {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
setId(id: number): void {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Méthode abstraite pour être implémentée par les classes dérivées
|
||||||
|
abstract ToString(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Indice
|
@ -0,0 +1,17 @@
|
|||||||
|
import EdgesIndice from "./EdgesIndice";
|
||||||
|
|
||||||
|
class NbEdgesIbndice extends EdgesIndice {
|
||||||
|
private nbNeighbors: number;
|
||||||
|
|
||||||
|
constructor(id: number, nbNeighbors: number) {
|
||||||
|
super(id);
|
||||||
|
this.nbNeighbors = nbNeighbors;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implémentation de la méthode abstraite
|
||||||
|
ToString(): string {
|
||||||
|
return "La personne a au moins " + this.nbNeighbors + " amis";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NbEdgesIbndice
|
@ -0,0 +1,83 @@
|
|||||||
|
import Sport from "./Sport";
|
||||||
|
import Color from "./Color";
|
||||||
|
|
||||||
|
class Person {
|
||||||
|
private id: number;
|
||||||
|
private name: string;
|
||||||
|
private age: number;
|
||||||
|
private color: Color;
|
||||||
|
private sports: Sport[];
|
||||||
|
private friends: Person[];
|
||||||
|
|
||||||
|
constructor(id: number, name: string, age: number, color: Color, sports: Sport[], friends: Person[]) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.age = age;
|
||||||
|
this.color = color;
|
||||||
|
this.sports = sports;
|
||||||
|
this.friends = friends;
|
||||||
|
}
|
||||||
|
|
||||||
|
getId(): number {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
setId(id: number): void {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter and setter for name
|
||||||
|
getName(): string {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
setName(name: string): void {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter and setter for age
|
||||||
|
getAge(): number {
|
||||||
|
return this.age;
|
||||||
|
}
|
||||||
|
|
||||||
|
setAge(age: number): void {
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter and setter for color
|
||||||
|
getColor(): Color {
|
||||||
|
return this.color;
|
||||||
|
}
|
||||||
|
|
||||||
|
setColor(color: Color): void {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter and setter for sports
|
||||||
|
getSports(): Sport[] {
|
||||||
|
return this.sports;
|
||||||
|
}
|
||||||
|
|
||||||
|
addSport(sport: Sport): void {
|
||||||
|
this.sports.push(sport)
|
||||||
|
}
|
||||||
|
|
||||||
|
setSports(sports: Sport[]): void {
|
||||||
|
this.sports = sports;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter and setter for friends
|
||||||
|
getFriends(): Person[] {
|
||||||
|
return this.friends;
|
||||||
|
}
|
||||||
|
|
||||||
|
addFriend(friend: Person): void {
|
||||||
|
this.friends.push(friend);
|
||||||
|
}
|
||||||
|
|
||||||
|
setFriends(friends: Person[]): void {
|
||||||
|
this.friends = friends;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Person
|
@ -0,0 +1,23 @@
|
|||||||
|
import Person from "./Person";
|
||||||
|
|
||||||
|
class PersonNetwork{
|
||||||
|
private persons : Person[]
|
||||||
|
|
||||||
|
constructor(persons: Person[]){
|
||||||
|
this.persons = persons;
|
||||||
|
}
|
||||||
|
|
||||||
|
getPersons(): Person[]{
|
||||||
|
return this.persons;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPersons(persons: Person[]){
|
||||||
|
this.persons = persons
|
||||||
|
}
|
||||||
|
|
||||||
|
addPerson(person: Person){
|
||||||
|
this.persons.push(person)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PersonNetwork
|
@ -0,0 +1,10 @@
|
|||||||
|
enum Sport {
|
||||||
|
FOOT,
|
||||||
|
RUGBY,
|
||||||
|
BASKET,
|
||||||
|
TENNIS,
|
||||||
|
CURLING,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Sport
|
||||||
|
|
@ -1,14 +1,15 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"resolveJsonModule": true,
|
// ...
|
||||||
"esModuleInterop": true,
|
"resolveJsonModule": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"esModuleInterop": true,
|
||||||
"moduleResolution": "node",
|
"allowSyntheticDefaultImports": true,
|
||||||
"target": "es5",
|
"moduleResolution": "node",
|
||||||
"lib": ["dom", "es2015"],
|
"target": "es5",
|
||||||
"jsx": "react",
|
"lib": ["dom", "es2015"],
|
||||||
"strict": true,
|
"jsx": "react",
|
||||||
|
"strict": true
|
||||||
},
|
},
|
||||||
}
|
// ...
|
||||||
// "noImplicitAny": false,
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue