Skip to content

Commit 4d76db7

Browse files
committed
Added bhaskara generation
Added bhaskara generation. Updated manual. Some bug fixes and improvements.
1 parent 70e36b9 commit 4d76db7

15 files changed

+127
-64
lines changed

Bhaskara.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
def BskrMenu(GameMenu):
88
utils.LogoType()
9+
print("<---Modo--->")
910
print("1 - Simples")
1011
print("2 - Padrão")
1112
print("x - Voltar")
1213
prop.BskrModeOpt = utils.getch()
1314
if prop.BskrModeOpt == 'x':
1415
return GameMenu()
16+
BskrModeLogo()
1517
print("<'exit' para sair>")
1618
print("<Precisão de "+str(shared.FloatPrec)+" decimal(is)>")
1719
while 1:
@@ -25,8 +27,7 @@ def BskrMenu(GameMenu):
2527

2628
def BskrMode1(GameMenu,BskrMenu,a,b,c): # Modo simples
2729
rs = (b**2)-4*a*c # Calcula delta
28-
print(a,"*x^2 + ",b,"*x + (",c,"). Delta = ")
29-
r = input()
30+
r = input(str(a)+"*x^2 + "+str(b)+"*x + ("+str(c)+"). Delta = ")
3031
if utils.CheckForFloat(r) == False: # Verificação para float
3132
if r == 'exit':
3233
return BskrMenu(GameMenu)
@@ -36,12 +37,12 @@ def BskrMode1(GameMenu,BskrMenu,a,b,c): # Modo simples
3637
if float(r) == rs:
3738
print("Certo")
3839
else:
39-
print("O certo seria ",rs)
40+
print("O certo seria "+str(rs))
4041

4142
def BskrMode2(GameMenu,BskrMenu,a,b,c): # Modo padrão
42-
rs1 = round(float(((b*-1)+sqrt((b**2)-4*a*c))/(2*a)),shared.FloatPrec)
43-
rs2 = round(float(((b*-1)-sqrt((b**2)-4*a*c))/(2*a)),shared.FloatPrec)
44-
print(a,"*x^2 + ",b,"*x + (",c,")")
43+
rs1 = round(float(((b*-1)+sqrt((b**2)-4*a*c))/(2*a)),shared.FloatPrec) # Calcula x1
44+
rs2 = round(float(((b*-1)-sqrt((b**2)-4*a*c))/(2*a)),shared.FloatPrec) # Calcula x2
45+
print(str(a)+"*x^2 + "+str(b)+"*x + ("+str(c)+")")
4546
r1 = input("x1 = ")
4647
r2 = input("x2 = ")
4748
if utils.CheckForFloat(r1) == False or utils.CheckForFloat(r2) == False:
@@ -53,5 +54,9 @@ def BskrMode2(GameMenu,BskrMenu,a,b,c): # Modo padrão
5354
if (float(r1) == rs1 and float(r2) == rs2) or (float(r1) == rs2 and float(r2) == rs2):
5455
print("Certo")
5556
else:
56-
print("O certo seria",rs1,"e",rs2)
57-
57+
print("O certo seria "+str(rs1)+" e "+str(rs2))
58+
59+
def BskrModeLogo(): # Mode-based logo
60+
utils.clear()
61+
with open('./design/ModeLogo/logotype'+str(prop.BskrModeOpt)+'.txt') as txt:
62+
print(txt.read())

Gen.py

+8-42
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,23 @@
1-
import os
1+
# Library for Mandrake | By vp1147
22
import shared
33
import utils
4-
from math import sqrt
54
import prop
5+
import GenPtgs
6+
import GenBskr
67

78
def GenMenu(InitMenu):
89
utils.LogoType()
910
print("1 - Teorema de Pitágoras")
11+
print("2 - Equação quadrática")
1012
print("x - Sair")
1113
GenMenuOpt = utils.getch()
1214
if GenMenuOpt == '1':
13-
PitagorasGen()
15+
GenPtgs.PtgsGen()
16+
return GenMenu(InitMenu)
17+
elif GenMenuOpt == '2':
18+
GenBskr.BskrGen()
1419
return GenMenu(InitMenu)
1520
elif GenMenuOpt == 'x':
1621
return InitMenu()
1722
else:
1823
return GenMenu(InitMenu)
19-
20-
def PitagorasGen():
21-
utils.LogoType()
22-
print("Valor mínimo das variáveis: ",shared.IntMin)
23-
print("Valor máximo das variáveis: ",shared.IntMax)
24-
print("Precisão de decimais: ",shared.FloatPrec)
25-
prop.GenPtgsModeOpt = str(input("Modo (1-2)(Ver manual): "))
26-
GenQuant = int(input("Quantidade para gerar: "))
27-
for i in range(0,GenQuant):
28-
x = utils.randint(shared.IntMin,shared.IntMax)
29-
y = utils.randint(shared.IntMin,shared.IntMax)
30-
z = utils.randint(shared.IntMin,shared.IntMax)
31-
if prop.GenPtgsModeOpt == '1':
32-
GenPtgsMode1(x,y,z)
33-
elif prop.GenPtgsModeOpt == '2':
34-
GenPtgsMode2(x,y,z)
35-
utils.getch()
36-
37-
def GenPtgsMode1(x,y,z): # Modo simples
38-
if x >= y and x >= z: # Caso x maior
39-
rs = (y**2)+(z**2)
40-
print("c1 = ",y,", c2 = ",z,", hip = raiz quadrada de ",rs)
41-
elif y >= x and y >= z: # Caso y maior
42-
rs = (x**2)+(z**2)
43-
print("c1 = ",x,", c2 = ",z,", hip = raiz quadrada de ",rs)
44-
elif z >= x and z >= y: # Caso z maior
45-
rs = (x**2)+(y**2)
46-
print("c1 = ",x,", c2 = ",y,", hip = raiz quadrada de ",rs)
47-
48-
def GenPtgsMode2(x,y,z): # Modo padrão
49-
if x >= y and x >= z: # Caso x maior
50-
rs = round(sqrt((y**2)+(z**2)),shared.FloatPrec)
51-
print("c1 = ",y,", c2 = ",z,", hip = ",rs)
52-
elif y >= x and y >= z: # Caso y maior
53-
rs = round(sqrt((x**2)+(z**2)),shared.FloatPrec)
54-
print("c1 = ",x,", c2 = ",z,", hip = ",rs)
55-
elif z >= x and z >= y: # Caso z maior
56-
rs = round(sqrt((x**2)+(y**2)),shared.FloatPrec)
57-
print("c1 = ",x,", c2 = ",y,", hip = ",rs)

GenBskr.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Library for Mandrake (Gen functions) | By vp1147
2+
import shared
3+
import utils
4+
import prop
5+
from math import sqrt
6+
7+
def BskrGen():
8+
utils.LogoType()
9+
print("<---Gerar equação quadrática--->")
10+
print("Valor mínimo das variáveis: ",shared.IntMin)
11+
print("Valor máximo das variáveis: ",shared.IntMax)
12+
print("Precisão de decimais: ",shared.FloatPrec)
13+
prop.GenBskrModeOpt = str(input("Modo (1-2)(Ver manual): "))
14+
GenQuant = int(input("Quantidade para gerar: "))
15+
for i in range(0,GenQuant):
16+
a = utils.randint(shared.IntMin,shared.IntMax)
17+
b = utils.randint(shared.IntMin,shared.IntMax)
18+
c = (utils.randint(shared.IntMin,shared.IntMax))*-1
19+
if prop.GenBskrModeOpt == '1':
20+
GenBskrMode1(a,b,c)
21+
elif prop.GenBskrModeOpt == '2':
22+
GenBskrMode2(a,b,c)
23+
utils.getch()
24+
25+
def GenBskrMode1(a,b,c):
26+
rs = (b**2)-4*a*c # Calcula delta
27+
print(str(a)+"*x^2 + "+str(b)+"*x + ("+str(c)+")")
28+
print("a = "+str(a)+" | b = "+str(b)+" | c = "+str(c)) # Mostra a, b e c
29+
print("Delta = "+str(rs))
30+
31+
def GenBskrMode2(a,b,c):
32+
rs1 = round(float(((b*-1)+sqrt((b**2)-4*a*c))/(2*a)),shared.FloatPrec) # Calcula x1
33+
rs2 = round(float(((b*-1)-sqrt((b**2)-4*a*c))/(2*a)),shared.FloatPrec) # Calcula x2
34+
print(str(a)+"*x^2 + "+str(b)+"*x + ("+str(c)+")")
35+
print("a = "+str(a)+" | b = "+str(b)+" | c = "+str(c)) # Mostra a, b e c
36+
print("x1 = "+str(rs1)+" | x2 = "+str(rs2))

GenPtgs.py

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Library for Mandrake (Gen functions) | By vp1147
2+
3+
import shared
4+
import utils
5+
import prop
6+
from math import sqrt
7+
8+
def PtgsGen():
9+
utils.LogoType()
10+
print("<---Gerar Teorema de Pítágoras--->")
11+
print("Valor mínimo das variáveis: ",shared.IntMin)
12+
print("Valor máximo das variáveis: ",shared.IntMax)
13+
print("Precisão de decimais: ",shared.FloatPrec)
14+
prop.GenPtgsModeOpt = str(input("Modo (1-2)(Ver manual): "))
15+
GenQuant = int(input("Quantidade para gerar: "))
16+
for i in range(0,GenQuant):
17+
x = utils.randint(shared.IntMin,shared.IntMax)
18+
y = utils.randint(shared.IntMin,shared.IntMax)
19+
z = utils.randint(shared.IntMin,shared.IntMax)
20+
if prop.GenPtgsModeOpt == '1':
21+
GenPtgsMode1(x,y,z)
22+
elif prop.GenPtgsModeOpt == '2':
23+
GenPtgsMode2(x,y,z)
24+
utils.getch()
25+
26+
def GenPtgsMode1(x,y,z): # Modo simples
27+
if x >= y and x >= z: # Caso x maior
28+
rs = (y**2)+(z**2)
29+
print("c1 = "+str(y)+", c2 = "+str(z)+", hip = raiz quadrada de "+str(rs))
30+
elif y >= x and y >= z: # Caso y maior
31+
rs = (x**2)+(z**2)
32+
print("c1 = "+str(x)+", c2 = "+str(z)+", hip = raiz quadrada de "+str(rs))
33+
elif z >= x and z >= y: # Caso z maior
34+
rs = (x**2)+(y**2)
35+
print("c1 = "+str(x)+", c2 = "+str(y)+", hip = raiz quadrada de "+str(rs))
36+
37+
def GenPtgsMode2(x,y,z): # Modo padrão
38+
if x >= y and x >= z: # Caso x maior
39+
rs = round(sqrt((y**2)+(z**2)),shared.FloatPrec)
40+
print("c1 = "+str(y)+", c2 = "+str(z)+", hip = "+str(rs))
41+
elif y >= x and y >= z: # Caso y maior
42+
rs = round(sqrt((x**2)+(z**2)),shared.FloatPrec)
43+
print("c1 = "+str(x)+", c2 = "+str(z)+", hip = "+str(rs))
44+
elif z >= x and z >= y: # Caso z maior
45+
rs = round(sqrt((x**2)+(y**2)),shared.FloatPrec)
46+
print("c1 = "+str(x)+", c2 = "+str(y)+", hip = "+str(rs))
47+

Pit.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def PtgsMenu(GameMenu):
88
utils.LogoType()
9-
print("<---- Modos ---->")
9+
print("<---Modo--->")
1010
print("1 - Simples")
1111
print("2 - Padrão")
1212
print("x - Voltar p/ Inicio")
@@ -27,15 +27,15 @@ def PtgsMenu(GameMenu):
2727

2828
def PtgsMode1(PtgsMenu,GameMenu,x,y,z): # Modo simples
2929
if x >= y and x >= z: # Caso x maior
30-
print("c1 = ",y,", c2 = ",z,", hip = raiz quadrada de ")
30+
print("c1 = "+str(y)+", c2 = "+str(z)+", hip = raiz quadrada de ")
3131
rs = (y**2)+(z**2)
3232
r = input()
3333
elif y >= x and y >= z: # Caso y maior
34-
print("c1 = ",x,", c2 = ",z,", hip = raiz quadrada de ")
34+
print("c1 = "+str(x)+", c2 = "+str(z)+", hip = raiz quadrada de ")
3535
rs = (x**2)+(z**2)
3636
r = input()
3737
elif z >= x and z >= y: # Caso z maior
38-
print("c1 = ",x,", c2 = ",y,", hip = raiz quadrada de ")
38+
print("c1 = "+str(x)+", c2 = "+str(y)+", hip = raiz quadrada de ")
3939
rs = (x**2)+(y**2)
4040
r = input()
4141
if utils.CheckForFloat(r) == False: # Verificação para float
@@ -47,19 +47,19 @@ def PtgsMode1(PtgsMenu,GameMenu,x,y,z): # Modo simples
4747
if float(r) == rs:
4848
print("Certo")
4949
else:
50-
print("O certo seria ",rs)
50+
print("O certo seria "+str(rs))
5151

5252
def PtgsMode2(PtgsMenu,GameMenu,x,y,z): # Modo padrão
5353
if x >= y and x >= z: # Caso x maior
54-
print("c1 = ",y,", c2 = ",z,", hip = ")
54+
print("c1 = "+str(y)+", c2 = "+str(z)+", hip = ")
5555
rs = round(sqrt((y**2)+(z**2)),shared.FloatPrec)
5656
r = input()
5757
elif y >= x and y >= z: # Caso y maior
58-
print("c1 = ",x,", c2 = ",z,", hip = ")
58+
print("c1 = "+str(x)+", c2 = "+str(z)+", hip = ")
5959
rs = round(sqrt((x**2)+(z**2)),shared.FloatPrec)
6060
r = input()
6161
elif z >= x and z >= y: # Caso z maior
62-
print("c1 = ",x,", c2 = ",y,", hip = ")
62+
print("c1 = "+str(x)+", c2 = "+str(y)+", hip = ")
6363
rs = round(sqrt((x**2)+(y**2)),shared.FloatPrec)
6464
r = input()
6565
if utils.CheckForFloat(r) == False:
@@ -71,7 +71,7 @@ def PtgsMode2(PtgsMenu,GameMenu,x,y,z): # Modo padrão
7171
if float(r) == rs:
7272
print("Certo")
7373
else:
74-
print("O certo seria ",rs)
74+
print("O certo seria "+str(rs))
7575

7676
def PitModeLogo(): # Mode-based logo
7777
utils.clear()

__pycache__/Arit.cpython-37.pyc

1.7 KB
Binary file not shown.

__pycache__/Bhaskara.cpython-37.pyc

346 Bytes
Binary file not shown.

__pycache__/Gen.cpython-37.pyc

-1.22 KB
Binary file not shown.

__pycache__/GenBskr.cpython-37.pyc

1.63 KB
Binary file not shown.

__pycache__/GenPtgs.cpython-37.pyc

1.72 KB
Binary file not shown.

__pycache__/Pit.cpython-37.pyc

121 Bytes
Binary file not shown.

__pycache__/prop.cpython-37.pyc

22 Bytes
Binary file not shown.

gen.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# DEPRECATED
2+
13
import utils
24
import math
35
import os

man.txt

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
Teorema de Pitágoras:
2-
Modo:
3-
Simples: O usuário informa a raiz, sem necessidade de a calcular;
4-
Padrão: O usuário calcula o resultado com uma certa precisão.
1+
<---Manual--->
2+
3+
# Teorema de Pitágoras:
4+
# Modo:
5+
# 1 - Simples: O usuário informa a raiz, sem necessidade de a calcular;
6+
# 2 - Padrão: O usuário calcula o resultado com uma certa precisão definível.
7+
# Equação quadrática:
8+
# Modo:
9+
# 1 - Simples: O usuário informa o delta;
10+
# 2 - Padrão: O usuário informa as raízes (x1 e x2) com uma certa precisão definível.

prop.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
VarArrangeOpt = ''
33
PtgsOpt = ''
44
AritOpt = ''
5-
RandLogo = 0 # From utils
5+
RandLogo = 0
66
GenPtgsModeOpt = ''
7+
GenBskrModeOpt = ''
78
BskrModeOpt = ''

0 commit comments

Comments
 (0)