-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOperacao.js
More file actions
91 lines (78 loc) · 2.07 KB
/
Operacao.js
File metadata and controls
91 lines (78 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class Operacao{
constructor(op1,oper,op2,resp){
this._op1 = op1;
this._oper = oper;
this._op2 = op2;
this._resp = resp;
this._texto = "não verificada"
}
get op1(){
return this._op1;
}
get oper(){
return this._oper;
}
get op2(){
return this._op2;
}
get resp(){
return this._resp;
}
get texto(){
return this._texto;
}
set texto(umTexto){
this._texto = umTexto;
}
static sorteiaOperacaoSomaN1(){
let op1 = Math.floor(Math.random() * (101));
let op2 = Math.floor(Math.random() * (101));
let oper = "+";
let resp = op1+op2;
return new Operacao(op1,oper,op2,resp);
}
static sorteiaOperacaoSomaN2(){
let op1 = Math.floor(Math.random() * (1001));
let op2 = Math.floor(Math.random() * (101));
let oper = "+";
let resp = op1+op2;
return new Operacao(op1,oper,op2,resp);
}
static sorteiaOperacaoSomaN3(){
let op1 = Math.floor(Math.random() * (1001));
let op2 = Math.floor(Math.random() * (1001));
let oper = "+";
let resp = op1+op2;
return new Operacao(op1,oper,op2,resp);
}
static sorteiaOperacaoSubN1(){
let op1 = Math.floor(Math.random() * 10)*10;
if (op1 < 10){
op1 = 10;
}
let op2 = Math.floor(Math.random() * (101));
if (op1 < op2){
let aux = op1;
op1 = op2;
op2 = aux;
}
let oper = "-";
let resp = op1-op2;
return new Operacao(op1,oper,op2,resp);
}
static sorteiaOperacaoSubN2(){
let op1 = Math.floor(Math.random() * (101));
let op2 = Math.floor(Math.random() * (101));
if (op1 < op2){
let aux = op1;
op1 = op2;
op2 = aux;
}
let oper = "-";
let resp = op1-op2;
return new Operacao(op1,oper,op2,resp);
}
toString(){
return this.op1+"-"+this.oper+"-"+this.op2+":"+this.texto;
}
}