I have a JAVA project that has code in it to start but no code in the two classes it gives you. I am new to JAVA and really need help on this. I added my code to the Treasure class and now I am getting:
Syntax error on tokens, delete these tokens and Syntax error, insert ";" to complete BlockStatements. Why am I getting these errors? What did I miss?
Here is the already Java code:
package mythical.controllers;
import java.text.NumberFormat;
import mythical.model.Treasure;
public class TreasureDemo {
private Treasure largeTreasure;
private Treasure smallTreasure;
private NumberFormat currencyFormatter;
public TreasureDemo() {
this.largeTreasure = new Treasure(105);
this.smallTreasure = new Treasure(10);
this.currencyFormatter = NumberFormat.getCurrencyInstance();
}
public void testTreasure() {
this.describeTreasure2("New large treasure", this.largeTreasure, 105, 25452.0);
this.describeTreasure2("New small treasure", this.smallTreasure, 10, 2424.0);
System.out.println();
System.out.println("~~~~ The treasures get found ~~~~");
this.largeTreasure.getsFound();
this.smallTreasure.getsFound();
System.out.println();
this.describeTreasure2("Found large treasure", this.largeTreasure, 0, 0.0);
this.describeTreasure2("Found small treasure", this.smallTreasure, 0, 0.0);
System.out.println();
}
public void describeTreasure2(String message, Treasure theTreasure,
int expectedWeight, double expectedValue) {
System.out.println(message);
System.out.println("\tExpected weight: \t" + expectedWeight);
System.out.println("\tActual weight: \t\t" + theTreasure.getWeight());
System.out.println("\tExpected value: \t" + this.currencyFormatter.format(expectedValue));
System.out.println("\tActual value: \t\t" + this.currencyFormatter.format(theTreasure.getValue()));
System.out.println();
}
}
Here is the Class:
package mythical.model;
public class Treasure {
private int theTreasure;
private int largeTreasure;
private int smallTreasure;
public Treasure() {
this.theTreasure = 0;
this.largeTreasure = 0;
this.smallTreasure = 0;
}
public Treasure(int largeTreasure){
this.largeTreasure = largeTreasure;
}
public void getLargeTreasure(){
this.largeTreasure = this.largeTreasure + 105;
}
public void getSmallTreasure(){
this.smallTreasure = this.smallTreasure + 10;
}
public int getWeight(){
return this.largeTreasure;
}
public double getValue(){
return this.largeTreasure * 242.40;
}
public int getsFound(){
return this.largeTreasure;
}
public int expectedWeight(){
return this.largeTreasure + 105;
}
}
}
}
Please help me.
What I have tried:
I have tried different ways to start the constructor but no luck. New to JAVA.