Untitled
Never
package com.cloakedstar.occ; import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; public class Counter { public static final String lossPath = "wins.txt"; public static final String winPath = "losses.txt"; public static void main(String[] args) { // TODO Auto-generated method stub setUpZeroes(); printGames(); } public static void printGames() { if(accessWins() + accessLosses() != 0) { System.out.print("Your current win/loss ratio is: " + accessWins() + " to " + accessLosses()); int totalGames = accessWins() + accessLosses(); double percent = ( (double) accessWins() / (double) totalGames); System.out.println(" or " + (percent * 100) + "%"); } System.out.println("Type \"win\" or \"loss\" to indicate you have lost or won a game."); userInput(); } @SuppressWarnings("resource") public static void userInput() { Scanner userInput = new Scanner(System.in); String game = null; game = userInput.nextLine(); if(game.equalsIgnoreCase("win")){ giveWin(); } else if(game.equalsIgnoreCase("loss")){ giveLoss(); } else { System.out.println("Unsupported input. Please type \"win\" or \"loss\""); } printGames(); } static int accessWins() { try { new File(winPath).createNewFile(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { Scanner winScanner = new Scanner(new File(winPath)); if(winScanner.hasNextInt()) { int wins = winScanner.nextInt(); winScanner.close(); return wins; } winScanner.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return 0; } static int accessLosses() { try { new File(lossPath).createNewFile(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { Scanner lossScanner = new Scanner(new File(lossPath)); if(lossScanner.hasNextInt()) { int losses = lossScanner.nextInt(); lossScanner.close(); return losses; } lossScanner.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return 0; } static void setUpZeroes() { if(new File(winPath).isFile() && new File(lossPath).isFile()) return; try { PrintWriter winWriter = new PrintWriter(new FileWriter(new File(winPath), false)); winWriter.print(0); winWriter.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { PrintWriter lossWriter = new PrintWriter(new FileWriter(new File(lossPath), false)); lossWriter.print(0); lossWriter.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } static void giveWin() { try { int wins = accessWins(); PrintWriter winWriter = new PrintWriter(new FileWriter(new File(winPath), false)); wins++; winWriter.print(wins); winWriter.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } static void giveLoss() { try { int losses = accessLosses(); PrintWriter lossWriter = new PrintWriter(new FileWriter(new File(lossPath), false)); losses++; lossWriter.print(losses); lossWriter.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
Raw Text
-
Untitled
10 min ago
-
Multiple Cumshots Cumpilation 2023 - my favorite cum baths - small MILF + HUGE loads YummyCouple
24 min ago
-
https://rapid-lean-keto-acv-gummies-us.godaddysites.com/
28 min ago
-
https://rapid-lean-keto-acv-gummies-us.godaddysites.com/
29 min ago
-
https://rapid-lean-keto-acv-gummies-us.godaddysites.com/
29 min ago
-
Untitled
37 min ago
-
https://www.linkedin.com/events/oemketogummiesunitedkingdomnatu7189477585951629312/
43 min ago
-
BRAZZERS - Robbin Banx & MJ Fresh Get On Stage And Share Duncan's Delicious Cock In A Hot 3
54 min ago
-
Untitled
57 min ago
-
Discover Your Perfect Wedding Venue in Karnal near Delhi with CYJ Events
1 hour ago