Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions src/main/java/RewardValue.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
public class RewardValue {
private double cashValue;
private double milesValue;
private static final double MILES_TO_CASH_RATE = 0.0035;
private final double cashValue;
public static final double MILES_TO_CASH_CONVERSION_RATE = 0.0035;

public RewardValue(double cashValue) {
this.cashValue = cashValue;
}

public RewardValue(double milesValue) {
this.milesValue = milesValue;
this.cashValue = milesValue * MILES_TO_CASH_RATE;
public RewardValue(int milesValue) {
this.cashValue = convertToCash(milesValue);
}

private static int convertToMiles(double cashValue) {
return (int) (cashValue / MILES_TO_CASH_CONVERSION_RATE);
}

private static double convertToCash(int milesValue) {
return milesValue * MILES_TO_CASH_CONVERSION_RATE;
}

public double getCashValue() {
return cashValue;
}


public double getMilesValue() {
return milesValue;
public int getMilesValue() {
return convertToMiles(this.cashValue);
}
}
}