Results 1 to 2 of 2
- 10-23-2012, 03:15 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 6
- Rep Power
- 0
Unable to call/declare methods. Causes errors such as "Object Not Found"
Hi guys, I was wondering if somebody could help me with a problem I'm having with one of my assignments. I want to have a music library program that can show the user the contents of his/her library as well as give the ability to edit or delete elements of an array list. For some reason when I create the methods (In a separate methods class?) they cause errors such as "Object not found" & illegal statement? Could somebody take a look at my code and tell me where I went wrong? I would be very grateful
.gif)
Main Class
package ca1;
import java.util.ArrayList;
import java.util.Scanner;
public class MainClass extends UserInput {
public String nextInt;
public static void main(String[] args) {
Scanner keyb = new Scanner(System.in);
UserInput ui = new UserInput(); // Declaring object to store user input
Scanner input = new Scanner(System.in);
Song s;
int opt;
//initial prompt
System.out.println("Welcome");
//do loop
do {
//declare array list
ArrayList<String> library = new ArrayList<>();
//add items to array list
library.add("Track 1");
library.add("Track 2");
library.add("Track 3");
library.add("Track 4");
library.add("Track 5");
//Menu Prompts
System.out.println("........ \n");
System.out.println("Press 0 to Exit\n");
System.out.println("Press 1 to View All Songs\n");
System.out.println("Press 2 to Add a Song\n");
System.out.println("Press 3 to Remove a Song\n");
System.out.println("Press 4 to Edit a Song\n");
System.out.println("Press 5 to Count Songs\n");
System.out.println("Press 5 to Delete All Songs\n");
opt = input.nextInt();
String opt1 = input.nextLine();
//if statements
if (opt == 0) {
System.out.println("You have selected option " + opt + "\n");
System.out.println("Goodbye!");
} else if (opt == 1) {
System.out.println("You have selected option " + opt + "\n");
System.out.println(library);
} else if (opt == 2) {
System.out.println("You have selected option " + opt + "\n");
System.out.println("Please name your new track");
} else if (opt == 3) {
System.out.println("You have selected option " + opt + "\n");
System.out.println("Please select what you would like to remove from your library");
System.out.println(library);
} else if (opt == 4) {
System.out.println("You have selected option " + opt + "\n");
System.out.println("What song would you like to edit?");
System.out.println(library);
} else if (opt == 5) {
System.out.println("You have selected option " + opt + "\n");
System.out.println("There are " + library.size() + " songs in your music library");
} else if (opt == 6) {
System.out.println("You have selected option " + opt + "\n");
System.out.println("Are you sure you want to delete all?");
System.out.println("Y/N");
if (opt1 == "y") {
library.removeAll(library);
} else if (opt1 == "n") {
System.out.println("okay");
}
} else {
System.out.println("Incorrect Entry");
}
} //do-while loop
while (opt > 0);
}
}
Method Class
package ca1;
public class Methods extends MainClass {
public void editLibrary(){
}
public void deleteSongs(){
}
public void exitSys (){
}
public void deleteAll()
{
System.out.println("You have selected option\n");
System.out.println("Are you sure you want to delete all?");
System.out.println("Y/N");
}
}
- 10-23-2012, 03:47 PM #2
Re: Unable to call/declare methods. Causes errors such as "Object Not Found"
You didn't bother to return to the first thread you started.
You didn't bother to find out and apply what Reeling told you about code tags.
Not the best way to continue to get free help on a forum, that.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Applet error "Fish.class not found" while running through Chrome.
By DaveAp7 in forum New To JavaReplies: 0Last Post: 02-02-2012, 07:24 AM -
"The Eclipse executable launcher was unable to locate its companion shared library"
By nhmllr in forum New To JavaReplies: 1Last Post: 08-07-2011, 02:35 AM -
What is the difference between an "Entity" and "Value Object"?
By vahini in forum Advanced JavaReplies: 4Last Post: 06-14-2011, 04:59 AM -
How can I prevent "found void but expected java.lang.String" ?
By trueblue in forum New To JavaReplies: 3Last Post: 05-21-2009, 03:48 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks