Метод не определен для типа leprechaun. Почему?
У меня есть проект Java, над которым я работаю, и я получаю эту ошибку:
Метод findTreasure (Treasure) не определен для типа Leprechaun.
Я пытаюсь выяснить, почему я получаю это, когда у меня есть это в моем коде? Может кто-нибудь, пожалуйста, посмотрит это для меня и даст мне знать, где я облажался? Вот мой код:
package mythical.controllers; import java.text.NumberFormat; import mythical.model.Leprechaun; import mythical.model.Treasure; /** * This is the driver for the informal test application * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ~~ DO NOT MODIFY THE CODE INSIDE TestDriver ~~ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * @author Kwesi Hopkins * @version 9/12/2016 * */ public class LeprechaunDemo { private Treasure treasurePail; private Treasure treasureChest; private Leprechaun patti; private NumberFormat currencyFormatter; /** * Creates a new LeprechaunDemo object with 2 Treasure * objects and an instance of a Leprechaun */ public LeprechaunDemo() { this.treasurePail = new Treasure(48); this.treasureChest = new Treasure(250); this.patti = new Leprechaun(100.0); this.currencyFormatter = NumberFormat.getCurrencyInstance(); } /** * Runs a set of tests for the Leprechaun's behavior */ public void testLeprechaun() { this.describeLeprechaun("Patti's initial value", 100.00); System.out.println("Patti says:"); System.out.println("\tExpected:\t\"Top o' the mornin to ya!\""); System.out.println("\tActual:\t\t\"" + this.patti.getGreeting() + "\""); System.out.println(); this.patti.findTreasure(this.treasurePail); this.describeLeprechaun("Patti's value after finding the small treasure", 11735.2); System.out.println("Small treasure's value after being found:"); System.out.println("\tExpected:\t$0.00"); System.out.println("\tActual:\t\t" + this.currencyFormatter.format(this.treasurePail.getValue())); System.out.println(); this.patti.meetPerson(); this.describeLeprechaun("Patti's value after giving away first time", 7627.88); this.patti.meetPerson(); this.describeLeprechaun("Patti's value after giving away second time", 4958.122); this.patti.findTreasure(this.treasureChest); this.describeLeprechaun("Patti's value after finding the large treasure", 65558.122); System.out.println("Large treasure's value after being found:"); System.out.println("\tExpected:\t$0.00"); System.out.println("\tActual:\t\t" + this.currencyFormatter.format(this.treasureChest.getValue())); } /** * Helper method that accepts a message and the expected value * * @param message The message to be displayed * @param expectedValue The expected value */ public void describeLeprechaun(String message, double expectedValue) { System.out.println(message); System.out.println("\tExpected: \t" + this.currencyFormatter.format(expectedValue)); System.out.println("\tActual: \t" + this.currencyFormatter.format(this.patti.getAssetValue())); System.out.println(); } }
Вот код класса:
package mythical.model; public class Leprechaun{ private int treasurePail; private int treasureChest; private double patti; public Leprechaun(){ this.treasurePail = 0; this.treasureChest = 0; this.patti = 0; } public Leprechaun(double patti){ this.patti = patti; } public void chooseTreasurePail(){ this.treasurePail = this.treasurePail + 48; } public void chooseTreasureChest(){ this.treasureChest = this.treasureChest + 250; } public void choosePatti(){ this.patti = this.patti + 100.00; } public String getGreeting() { return "Top o' the mornin to ya!"; } public double getAssetValue(){ return this.patti; } public int meetPerson(){ return this.treasurePail; } }
Что я уже пробовал:
Я искал свой код вверх и вниз, чтобы найти свои ошибки.