Hello
Everytime i compile this i keep getting an error on non-static method can not bu passed to static method, i understand that. But how can i get around this, without making the non-static method static , because it has variable relating to otha methods ... i also keep getting an array error for the variables userTime & i .
Can neone help me one this one please its very vital im almost done here..
Thanks For Ne Help Given In Advance
import java.util.Vector;
import java.io.*;
public class Schedule
{
Vector ch1Time = new Vector();
Vector ch2Time = new Vector();
public static void main (String args[])
{
mainMenu();
}
public void mainMenu()
{
int choice1 = 0;
do
{
System.out.println("************* CHANNEL ONE MENU *************");
System.out.println("ENTER 1 TO ADD PROGRAMMES TO CHANNEL ONE");
System.out.println("ENTER 2 TO REMOVE PROGRAMMES FROM CHANNEL ONE");
System.out.println("ENTER 3 TO FIND EMPTY SPACE IN CHANNEL ONE");
System.out.println("ENTER 4 TO ADD PROGRAMMES TO CHANNEL TWO");
System.out.println("ENTER 5 TO REMOVE PROGRAMMES FROM CHANNEL TWO");
System.out.println("ENTER 6 TO FIND EMPTY SPACE IN CHANNEL TWO");
System.out.println("ENTER 0 TO EXIT MENU");
try
{
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(System.in));
String i = reader.readLine();
choice1 = Integer.parseInt(i);
if(choice1==1)
{
addProgrammesCH1();
}
else if (choice1==2)
{
removeProgrammesCH1();
}
else if (choice1==3)
{
// checkCH1();
}
else if(choice1==4)
{
// addProgrammesCH2();
}
else if (choice1==5)
{
// removeProgrammesCH2();
}
else if (choice1==6)
{
// checkCH2();
}
else if (choice1==0)
{
System.exit(0);
}
}
catch (IOException e)
{
System.out.println(e);
}
}while(choice1!=0);
}
public void addProgrammesCH1()
{
int choice2 =0;
int userTime;
do
{
System.out.println("********** ADD TO CHANNEL ONE **********");
System.out.println("ENTER 1 TO CHOOSE A DAY AND TIME");
// System.out.println("ENTER 2 TO CHOOSE A TIME");
System.out.println("ENTER 3 TO CHOOSE A PROGRAM");
System.out.println("ENTER 4 TO GO TO MAIN MENU");
System.out.println("ENTER 0 TO EXIT MENU");
try
{
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(System.in));
choice2 = Integer.parseInt(reader.readLine());
if(choice2==1)
{
schDay();
}
/* else if (choice2==2)
{
schTime();
}
*/
else if (choice2==3)
{
// schProgram();
}
else if (choice2==4)
{
mainMenu();
}
else if (choice2==0)
{
System.exit(0);
}
}
catch (Exception e)
{
System.out.println(e);
}
}while(choice2!=0);
}
public void schDay()
{
int choice2 =0;
do
{
System.out.println("********** ADD TO CHANNEL ONE **********");
System.out.println("ENTER 1 TO ADD TO SUNDAY");
System.out.println("ENTER 2 TO ADD TO SUNDAY");
System.out.println("ENTER 3 TO ADD TO SUNDAY");
System.out.println("ENTER 4 TO ADD TO SUNDAY");
System.out.println("ENTER 5 TO ADD TO SUNDAY");
System.out.println("ENTER 6 TO ADD TO SUNDAY");
System.out.println("ENTER 7 TO ADD TO SUNDAY");
System.out.println("ENTER 0 TO EXIT MENU");
ch1Time.insertElementAt(" 6:00",0);
ch1Time.insertElementAt(" 6:30",1);
ch1Time.insertElementAt(" 7:00",2);
ch1Time.insertElementAt(" 7:30",3);
ch1Time.insertElementAt(" 8:00",4);
ch1Time.insertElementAt(" 8:30",5);
ch1Time.insertElementAt(" 9:00",6);
ch1Time.insertElementAt(" 9:30",7);
ch1Time.insertElementAt(" 10:00",8);
ch1Time.insertElementAt(" 10:30",9);
ch1Time.insertElementAt(" 11:00",10);
ch1Time.insertElementAt(" 11:30",11);
ch1Time.insertElementAt(" 12:00",12);
ch1Time.insertElementAt(" 12:30",13);
ch1Time.insertElementAt(" 13:00",14);
ch1Time.insertElementAt(" 13:30",15);
ch1Time.insertElementAt(" 14:00",16);
ch1Time.insertElementAt(" 14:30",17);
ch1Time.insertElementAt(" 15:00",18);
ch1Time.insertElementAt(" 15:30",19);
ch1Time.insertElementAt(" 16:00",20);
ch1Time.insertElementAt(" 16:30",21);
ch1Time.insertElementAt(" 17:00",22);
ch1Time.insertElementAt(" 17:30",23);
ch1Time.insertElementAt(" 18:00",24);
ch1Time.insertElementAt(" 18:30",25);
ch1Time.insertElementAt(" 19:00",26);
ch1Time.insertElementAt(" 19:30",27);
ch1Time.insertElementAt(" 20:00",28);
ch1Time.insertElementAt(" 20:30",29);
ch1Time.insertElementAt(" 21:00",30);
ch1Time.insertElementAt(" 21:30",31);
ch1Time.insertElementAt(" 22:00",32);
ch1Time.insertElementAt(" 22:00",33);
ch1Time.insertElementAt(" 23:00",34);
ch1Time.insertElementAt(" 23:00",35);
try
{
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(System.in));
choice2 = Integer.parseInt(reader.readLine());
if(choice2==1)
{
/* for(int i = 0; i<ch1Time.size(); i++)
{
if(userTime.equals(ch1Time.elementAt(i))
{
return i;
}
}*/
schTime();
}
else if (choice2==2)
{
//
}
else if (choice2==3)
{
//
}
else if (choice2==4)
{
//
}
else if (choice2==5)
{
//
}
else if (choice2==6)
{
//
}
else if (choice2==7)
{
//
}
else if (choice2==0)
{
System.exit(0);
}
}
catch (Exception e)
{
System.out.println(e);
}
}while(choice2!=0);
}
public void schTime()
{
System.out.println("ENTER TIME : ");
try
{
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(System.in));
userTime = Integer.parseInt(reader.readLine());
if(userTime.equals(ch1Time.elementAt(i)))
{
ch1Time.elementAt(i)= "";
ch1Time.remove(i);
ch1Time.insertElementAt("",i);
}
else
{
System.out.println(" Time is not available");
}
}
catch (Exception e)
{
System.out.println(e);
}
}
public void removeProgrammesCH1()
{
}
}