Following the Oracle Acadamy Java Fundamentals and I walked into a wall(I dont understand how its explained in the acadamy)
The Try It/Solve It:
- Create a method
nicestFishthat takes in two fish as parameters, compares the friendliness level of two fish, and returns the fish with the higher friendliness. Test this method with the fish defined in problem 6.
Main:
public class index { public static void main(String[] args) { Fish Amber = new Fish("AngelFish", 5); Fish James = new Fish("Guppy", 3); } } Class:
public class Fish { String typeOfFish; int friendliness; public Fish(){ typeOfFish = "unknown"; friendliness = 3; } public Fish(String t, int f) { this.typeOfFish = t; this.friendliness = f; } public int getFriendliness(){ return friendliness; } }
compareTomethod ?fish.getFriendliness()