Skip to content

Commit

Permalink
Classes e casos de teste
Browse files Browse the repository at this point in the history
  • Loading branch information
reinaldofs committed Jul 6, 2017
1 parent 08be6ff commit dfd5642
Show file tree
Hide file tree
Showing 23 changed files with 866 additions and 3 deletions.
14 changes: 14 additions & 0 deletions utfpr_vvxpp/src/buildmac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mkdir output
javac parser/langX.java
javac langXrt/Runtime.java
java parser.langX "$1"
java -jar ~/jasmin-2.4/jasmin.jar "$1.$2.jas"
clear
java -classpath .:. $2

mkdir "output/$3"

cp "$1.arvore.txt" "output/$3"
cp "$2.class" "output/$3"
cp "saida.txt" "output/$3"
cp "$1" "output/$3"
2 changes: 1 addition & 1 deletion utfpr_vvxpp/src/mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ javac parser/langX.java
javac langXrt/Runtime.java
java parser.langX ../ssamples/olamundo.x
java -jar ~/jasmin-2.4/jasmin.jar ../ssamples/olamundo.x.olamundo.jas
java -classpath .:. olamundo
java -classpath .:. olamundo
17 changes: 17 additions & 0 deletions utfpr_vvxpp/src/output/bubblesort1/Parametros:
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Parametros:
6
1
2
3
4
5
6


Saida:
vetor[0][0] = 1
vetor[1][0] = 2
vetor[2][0] = 3
vetor[3][0] = 4
vetor[4][0] = 5
vetor[5][0] = 6
54 changes: 54 additions & 0 deletions utfpr_vvxpp/src/output/bubblesort1/bubblesort.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class bubblesort{

int condicional(int v1, int v2){
if(v1 > v2) return 1;
return 0;
}

int start(){

int n,i;

print "Numero de valores do vetor: ";
read n;

//n = 5;

int vetor[][];

vetor = new int[n][1];

//vetor[0][0] = 5;
//vetor[1][0] = 7;
//vetor[2][0] = 3;
//vetor[3][0] = 8;
//vetor[4][0] = 1;

print "Digite os valores do vetor: ";

for (i = 0; i < n; i = i + 1){
read vetor[i][0];
}


int j, min, aux;

for (i = n; i >= 1; i = i - 1) {
for (j = 1; j < i; j = j + 1) {
if (vetor[j - 1][0] > vetor[j][0]) {
aux = vetor[j][0];
vetor[j][0] = vetor[j - 1][0];
vetor[j - 1][0] = aux;
}
}
}

for (i = 0; i < n; i = i + 1){
print "vetor["+i+"][0] = "+vetor[i][0]+ " \n" ;
}

return 0;

}

}
12 changes: 12 additions & 0 deletions utfpr_vvxpp/src/output/bubblesort2/Parametros:
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Parametros:
4
4
3
2
1

Saida:
vetor[0][0] = 1
vetor[1][0] = 2
vetor[2][0] = 3
vetor[3][0] = 4
54 changes: 54 additions & 0 deletions utfpr_vvxpp/src/output/bubblesort2/bubblesort.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class bubblesort{

int condicional(int v1, int v2){
if(v1 > v2) return 1;
return 0;
}

int start(){

int n,i;

print "Numero de valores do vetor: ";
read n;

//n = 5;

int vetor[][];

vetor = new int[n][1];

//vetor[0][0] = 5;
//vetor[1][0] = 7;
//vetor[2][0] = 3;
//vetor[3][0] = 8;
//vetor[4][0] = 1;

print "Digite os valores do vetor: ";

for (i = 0; i < n; i = i + 1){
read vetor[i][0];
}


int j, min, aux;

for (i = n; i >= 1; i = i - 1) {
for (j = 1; j < i; j = j + 1) {
if (vetor[j - 1][0] > vetor[j][0]) {
aux = vetor[j][0];
vetor[j][0] = vetor[j - 1][0];
vetor[j - 1][0] = aux;
}
}
}

for (i = 0; i < n; i = i + 1){
print "vetor["+i+"][0] = "+vetor[i][0]+ " \n" ;
}

return 0;

}

}
54 changes: 54 additions & 0 deletions utfpr_vvxpp/src/output/bubblesort3/bubblesort.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class bubblesort{

int condicional(int v1, int v2){
if(v1 > v2) return 1;
return 0;
}

int start(){

int n,i;

print "Numero de valores do vetor: ";
read n;

//n = 5;

int vetor[][];

vetor = new int[n][1];

//vetor[0][0] = 5;
//vetor[1][0] = 7;
//vetor[2][0] = 3;
//vetor[3][0] = 8;
//vetor[4][0] = 1;

print "Digite os valores do vetor: ";

for (i = 0; i < n; i = i + 1){
read vetor[i][0];
}


int j, min, aux;

for (i = n; i >= 1; i = i - 1) {
for (j = 1; j < i; j = j + 1) {
if (vetor[j - 1][0] > vetor[j][0]) {
aux = vetor[j][0];
vetor[j][0] = vetor[j - 1][0];
vetor[j - 1][0] = aux;
}
}
}

for (i = 0; i < n; i = i + 1){
print "vetor["+i+"][0] = "+vetor[i][0]+ " \n" ;
}

return 0;

}

}
42 changes: 42 additions & 0 deletions utfpr_vvxpp/src/output/classetrabalho1/classetrabalho.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Ler o ano de nascimento de uma pessoa e iformar sua idade
// se a indade for menor que 16 anos informar não pode trabalho
// se a indade for entre 16 e 18 anos informar menor aprendiz
// se a idade for maior que 18 anos informar contrato de trabalho

class classetrabalho{

int start(){

int anonascimento, idade;

print "digite o ano de nascimento: \n";
read anonascimento;

idade = 2017 - anonascimento;

print "idade: " + idade + "\n";

if(idade < 16){
print "nao pode trabalhar";

return 0;
}

if(idade > 18){
print "contrato de trabalho";

return 0;
}

if(idade >= 16){

if(idade <= 18){
print "menor aprendiz";
}
}

return 0;
}


}
42 changes: 42 additions & 0 deletions utfpr_vvxpp/src/output/classetrabalho2/classetrabalho.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Ler o ano de nascimento de uma pessoa e iformar sua idade
// se a indade for menor que 16 anos informar não pode trabalho
// se a indade for entre 16 e 18 anos informar menor aprendiz
// se a idade for maior que 18 anos informar contrato de trabalho

class classetrabalho{

int start(){

int anonascimento, idade;

print "digite o ano de nascimento: \n";
read anonascimento;

idade = 2017 - anonascimento;

print "idade: " + idade + "\n";

if(idade < 16){
print "nao pode trabalhar";

return 0;
}

if(idade > 18){
print "contrato de trabalho";

return 0;
}

if(idade >= 16){

if(idade <= 18){
print "menor aprendiz";
}
}

return 0;
}


}
42 changes: 42 additions & 0 deletions utfpr_vvxpp/src/output/classetrabalho3/classetrabalho.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Ler o ano de nascimento de uma pessoa e iformar sua idade
// se a indade for menor que 16 anos informar não pode trabalho
// se a indade for entre 16 e 18 anos informar menor aprendiz
// se a idade for maior que 18 anos informar contrato de trabalho

class classetrabalho{

int start(){

int anonascimento, idade;

print "digite o ano de nascimento: \n";
read anonascimento;

idade = 2017 - anonascimento;

print "idade: " + idade + "\n";

if(idade < 16){
print "nao pode trabalhar";

return 0;
}

if(idade > 18){
print "contrato de trabalho";

return 0;
}

if(idade >= 16){

if(idade <= 18){
print "menor aprendiz";
}
}

return 0;
}


}
21 changes: 21 additions & 0 deletions utfpr_vvxpp/src/output/fatorial1/fatorial.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// calcula o fatorial de um número

class fatorial{

int start()
{
int fat, n;
print "Insira um valor para o qual deseja calcular seu fatorial: ";
read n;

for(fat = 1; n > 1; n = n - 1){
fat = fat * n;
}

print "\nFatorial calculado: " + fat;

return 0;

}

}
Loading

0 comments on commit dfd5642

Please sign in to comment.