Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Decompiled with CFR 0_132.
- */
- package io.github.gronnmann.coinflipper.stats;
- import java.text.DecimalFormat;
- public class Stats {
- private int gamesWon;
- private int gamesLost;
- private double moneyUsed;
- private double moneyWon;
- private double moneyEarned;
- public Stats(int gamesWon, int gamesLost, double moneyUsed, double moneyWon) {
- this.gamesWon = gamesWon;
- this.gamesLost = gamesLost;
- this.moneyUsed = moneyUsed;
- this.moneyWon = moneyWon;
- }
- public int getGamesWon() {
- return this.gamesWon;
- }
- public int getGamesLost() {
- return this.gamesLost;
- }
- public double getMoneySpent() {
- return this.moneyUsed;
- }
- public double getMoneyWon() {
- return this.moneyWon;
- }
- public double getMoneyEarned() {
- return this.moneyEarned;
- }
- public double getWinPercentage() {
- double total = this.gamesWon + this.gamesLost;
- if (total == 0.0) {
- return 0.0;
- }
- double percentage1 = (double)this.gamesWon / total * 100.0;
- DecimalFormat df = new DecimalFormat("##0.00");
- return Double.parseDouble(df.format(percentage1).replace(',', '.'));
- }
- public void addWin() {
- ++this.gamesWon;
- }
- public void addLose() {
- ++this.gamesLost;
- }
- public void addMoneySpent(double amount) {
- this.moneyUsed += amount;
- this.calculateEarned();
- }
- public void addMoneyWon(double amount) {
- this.moneyWon += amount;
- this.calculateEarned();
- }
- private void calculateEarned() {
- this.moneyEarned = this.moneyWon - this.moneyUsed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement