* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package peixedoodio;
import java.util.Scanner;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
/**
*
* @author halis
*/
public class Peixedoodio {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
Scanner arquivoLeitura= null;
int peixe[] = new int[2];
int distancia;
int i = 10, a = 0;
PrintWriter arquivoEscrita = new PrintWriter(new FileWriter("resultado.txt"));
try {//abrindo arquivo para leitura
arquivoLeitura = new Scanner(new FileReader("numeros.txt"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while (arquivoLeitura.hasNext()){
System.out.println("obetendo a quantidades de movimentos do peixe 1 " + " "+ " nos seus primeiros "+ i + " segundos...");
distancia = arquivoLeitura.nextInt();
peixe[0] += distancia;
System.out.println("obetendo a quantidades de movimentos do peixe 2 " + " "+ " nos seus primeiros "+ i + " segundos...");
distancia = arquivoLeitura.nextInt();
peixe[1] += distancia;
a++;
i = i + 10;
}
if(peixe[0]>10){
peixe[0] = 10;
}
System.out.print("P1: |");
for(int ai = 0; ai < peixe[0]; ai++){
System.out.print(".");
}
System.out.print("><(((>º");
System.out.print("|");
if(peixe[1]>10){
peixe[1] = 10;
}
System.out.print("\nP2: |");
for(int ai = 0; ai < peixe[1]; ai++){
System.out.print(".");
}
System.out.print("><(((>º");
System.out.print("|");
System.out.println(" ");
if(peixe[0]>peixe[1]){
System.out.println("peixe 1 o vencedor");
}else{
if(peixe[1]>peixe[0]){
System.out.println("peixe 2 vencedor");
}else{
if(peixe[0]==peixe[1]){
System.out.println("empate essa pohaa");
}
}
}
}
}
Sem comentários:
Enviar um comentário