Cant find Symbol error

VaniDiodo

New Member
The compiler gives me an error message saying it can't find movies[x].getTitle() and movies[x].getYear. I've been wondering if it's a problem with going through the interface to get to the classesHere is the error:\[code\]MathewBorumP5.java:68: error: cannot find symbolSystem.out.printf("%-26s%-6s%-10s%-9s%-11s\n", movies[x].getTitle(),^symbol: method getTitle()location: interface ProfitableMathewBorumP5.java:69: error: cannot find symbol movies[x].getYear(), movies[x].calcRevenue(), ^symbol: method getYear()location: interface Profitable2 errors\[/code\]Here is my client class:\[code\]import java.util.Scanner;public class MathewBorumP5 { public static void main(String[] args) { int choice; boolean restart = true; Scanner input = new Scanner(System.in); Profitable[] movies = new Profitable[6]; movies[0] = new Animated("Beauty and the Beast", "Gary Trousdale", 1991, 10.0, 5.0, 2.0); movies[1] = new Animated("Peter Pan", "Clyde Geronimi", 1953, 2.0, 1.2, .5); movies[2] = new Documentary("Planet Earth", "Alastair Fothergill", 2006, 10, 20, 5); movies[3] = new Documentary("Drain the Ocean", "Steve Nichols", 2009, 9, 2,3); movies[4] = new Drama("The Shawshank Redemption", "Frank Darabont", 1994, 89, 7, 2); movies[5] = new Drama("The Godfather", "Francis Coppola", 1972, 10, 3, 5); do { menu(); System.out.print("Enter a number from 1 - 5: "); choice = input.nextInt(); System.out.print("\n"); switch(choice) { case 1: item1(movies); break; case 2: break; case 3: break; case 4: break; case 5: restart = false; break; default: System.out.print("You didn't enter a number between 1" + " and 5.\n"); break; } } while(restart == true);}public static void menu() { System.out.print("Warren Moore Movie Menu\n"); System.out.print("1. Show the list of movies in the array\n"); System.out.print("2. Display the total number of movies and the total" + " revenues\n"); System.out.print("3. Search movie by title\n"); System.out.print("4. Display movies sorted by profit in decreasing" + " order\n"); System.out.print("5. Exit\n");}public static void item1(Profitable[] movies) { double revenue; System.out.printf("%-26s%-6s%-10s%-9s%-11s\n", "Title", "Year", "Revenue", "Profit", "Category"); for(int x = 0; x <= 6; x++) { revenue = movies[x].calcRevenue(); System.out.printf("%-26s%-6s%-10s%-9s%-11s\n", movies[x].getTitle(), movies[x].getYear(), movies[x].calcRevenue(), movies[x].calcProfit(revenue), movies[x].category()); }}}\[/code\]Here are my separate classes. public class Animated extends Movie implements Profitable { private double rate; private double income;\[code\]public Animated() { super();}public Animated(String title, String director, int year, double cost, double rate, double income) { super(title, director, year, cost); this.rate = rate; this.income = income;}public double getRate() { return rate;}public void setRate(double rate) { this.rate = rate;}public double getIncome() { return income;}public void setIncome(double income) { this.income = income;}public String category() { return "Animated";}public double calcRevenue() { return (income * rate);}public double calcProfit(double revenue) { return (revenue - super.productionCost);}public String toString() { return (super.toString() + "");}}\[/code\]Number 2\[code\]public class Documentary extends Movie implements Profitable {private int distributors;private double premium;public Documentary() { super();}public Documentary(String title, String director, int year, double cost, int distributors, double premium) { super(title, director, year, cost); this.distributors = distributors; this.premium = premium;}public int getDistributors() { return distributors;}public void setDistributors(int distributors) { this.distributors = distributors;}public double getPremium() { return premium;}public void setPremium(double premium) { this.premium = premium;}public String category() { return "Documentary";}public double calcRevenue() { return (distributors * premium);}public double calcProfit(double revenue) { return (revenue - super.productionCost);}public String toString() { return (super.toString() + "");}}\[/code\]Number 3\[code\]public class Drama extends Movie implements Profitable {private int tickets;private double avgPrice;public Drama() { super();}public Drama(String title, String director, int year, double cost, int tickets, double avgPrice) { super(title, director, year, cost); this.tickets = tickets; this.avgPrice = avgPrice;}public int getTickets() { return tickets;}public void setTickets(int tickets) { this.tickets = tickets;}public String category() { return "Drama";}public double calcRevenue() { return (tickets * avgPrice);}public double calcProfit(double revenue) { return (revenue - super.productionCost);}public String toString() { return (super.toString() + "");}}\[/code\]And finally my interface.\[code\]public interface Profitable { public abstract String category(); public abstract double calcRevenue(); public abstract double calcProfit(double revenue);}\[/code\]
 
Back
Top