Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. /*
  2.  * Decompiled with CFR 0_132.
  3.  */
  4. package io.github.gronnmann.coinflipper.stats;
  5.  
  6. import java.text.DecimalFormat;
  7.  
  8. public class Stats {
  9.     private int gamesWon;
  10.     private int gamesLost;
  11.     private double moneyUsed;
  12.     private double moneyWon;
  13.     private double moneyEarned;
  14.  
  15.     public Stats(int gamesWon, int gamesLost, double moneyUsed, double moneyWon) {
  16.         this.gamesWon = gamesWon;
  17.         this.gamesLost = gamesLost;
  18.         this.moneyUsed = moneyUsed;
  19.         this.moneyWon = moneyWon;
  20.     }
  21.  
  22.     public int getGamesWon() {
  23.         return this.gamesWon;
  24.     }
  25.  
  26.     public int getGamesLost() {
  27.         return this.gamesLost;
  28.     }
  29.  
  30.     public double getMoneySpent() {
  31.         return this.moneyUsed;
  32.     }
  33.  
  34.     public double getMoneyWon() {
  35.         return this.moneyWon;
  36.     }
  37.  
  38.     public double getMoneyEarned() {
  39.         return this.moneyEarned;
  40.     }
  41.  
  42.     public double getWinPercentage() {
  43.         double total = this.gamesWon + this.gamesLost;
  44.         if (total == 0.0) {
  45.             return 0.0;
  46.         }
  47.         double percentage1 = (double)this.gamesWon / total * 100.0;
  48.         DecimalFormat df = new DecimalFormat("##0.00");
  49.         return Double.parseDouble(df.format(percentage1).replace(',', '.'));
  50.     }
  51.  
  52.     public void addWin() {
  53.         ++this.gamesWon;
  54.     }
  55.  
  56.     public void addLose() {
  57.         ++this.gamesLost;
  58.     }
  59.  
  60.     public void addMoneySpent(double amount) {
  61.         this.moneyUsed += amount;
  62.         this.calculateEarned();
  63.     }
  64.  
  65.     public void addMoneyWon(double amount) {
  66.         this.moneyWon += amount;
  67.         this.calculateEarned();
  68.     }
  69.  
  70.     private void calculateEarned() {
  71.         this.moneyEarned = this.moneyWon - this.moneyUsed;
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement