Merge branch 'master' of https://codefirst.iut.uca.fr/git/HyperSet/HyperSet into algo
commit
e22fdbfd43
@ -1,7 +1,14 @@
|
||||
# HyperSet
|
||||
|
||||
2nd Year Project of IT BUT in Aubière
|
||||
|
||||
Created by :
|
||||
|
||||
## Description of the project
|
||||
|
||||
2nd Year Project of IT BUT in Aubière
|
||||
|
||||
## Subject
|
||||
|
||||
|
||||
[link of the initial project](https://codefirst.iut.uca.fr/git/cedric.bouhours/Projets_SAE_S4/src/branch/master/Projets/Projet_11.md)
|
||||
|
||||
## Created by :
|
||||
|
||||
LACOTE Raphaël JAULT Aurian ARNAL Rémi JACQUELIN Bastien
|
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Console</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Console - test </h1>
|
||||
|
||||
<section>
|
||||
|
||||
</section>
|
||||
<script src="../Model/emptyParameterException.js"></script>
|
||||
<script src="../Model/Card.js"></script>
|
||||
<script src="../Model/Card5.js"></script>
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -0,0 +1,28 @@
|
||||
// import { Card5 } from "../Model/Card5";
|
||||
// import('../Model/Card5');
|
||||
//import {Card} from '../Model/Card';
|
||||
|
||||
console.log("~#Test#~");
|
||||
let card4 = new Card('red','2','losange','full');
|
||||
console.group('Carte 4 attributes');
|
||||
console.log(`carte de 4 elements : ${card4.color}`);
|
||||
console.groupEnd();
|
||||
let card5 = new Card5('blue','2','losange','full','pointillet');
|
||||
console.group('Carte 5 attributes');
|
||||
console.log(`carte de 5 elements : ${card5.outline}`);
|
||||
console.log(`carte de 5 éléments instance de 5: ${card5 instanceof Card5}`);
|
||||
console.log(`carte de 5 éléments accès par méthode idx 0: ${card5.getAttributes()[0]}`);
|
||||
console.log(`carte de 5 éléments accès par méthode idx 4: ${card5.getAttributes()[4]}`);
|
||||
console.groupEnd();
|
||||
console.group('Error');
|
||||
try {
|
||||
let errCard = new Card5('blue','','losange','full','pointillet');
|
||||
}catch(errCard){
|
||||
if(errCard instanceof EmptyParamaterException){
|
||||
console.log('Error in constructor');
|
||||
}
|
||||
else{
|
||||
console.error(errCard);
|
||||
}
|
||||
}
|
||||
console.groupEnd();
|
@ -0,0 +1,33 @@
|
||||
class Card{
|
||||
constructor(color, number, shape, filling){
|
||||
if(!color){
|
||||
throw new EmptyParamaterException('Color');
|
||||
}
|
||||
if(!number){
|
||||
throw new EmptyParamaterException('Number');
|
||||
}
|
||||
if(!shape){
|
||||
throw new EmptyParamaterException('Shape');
|
||||
}
|
||||
if(!filling){
|
||||
throw new EmptyParamaterException('Filling');
|
||||
}
|
||||
this.color=color;
|
||||
this.number=number;
|
||||
this.shape=shape;
|
||||
this.filling=filling;
|
||||
}
|
||||
/**
|
||||
* @returns array of all attributes :
|
||||
idx 1 : color
|
||||
idx 2 : number
|
||||
idx 3 : shape
|
||||
idx 4 : filling
|
||||
idx 5 : null
|
||||
* @author Bastien Jacquelin
|
||||
*/
|
||||
getAttributes(){
|
||||
return [this.color,this.number,this.shape,this.filling];
|
||||
}
|
||||
|
||||
}//export {Card}
|
@ -0,0 +1,25 @@
|
||||
// import('.Card');
|
||||
|
||||
class Card5 extends Card {
|
||||
constructor(color, number, shape, filling, outline){
|
||||
super(color,number,shape,filling);
|
||||
if(!outline){
|
||||
throw new EmptyParamaterException('Outline');
|
||||
}
|
||||
this.outline=outline;
|
||||
}
|
||||
/**
|
||||
* @returns array of all attributes :
|
||||
idx 1 : color
|
||||
idx 2 : number
|
||||
idx 3 : shape
|
||||
idx 4 : filling
|
||||
idx 5 : outline
|
||||
* @author Bastien Jacquelin
|
||||
*/
|
||||
getAttributes(){
|
||||
// return [this.color,this.number,this.shape,this.filling,this.outline];
|
||||
return super.getAttributes().concat(this.outline);
|
||||
}
|
||||
}
|
||||
// export {Card5};
|
@ -0,0 +1,5 @@
|
||||
class EmptyParamaterException extends Error{
|
||||
constructor(field){
|
||||
super(`Field ${field} missing`);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue