I wrote a simple code to provide a mini system for a game ticket reservation and while running my project i got some errors in the following function as shown below in the code
Code:
public void reverseTicket(int seatNum,int gameCode,int categ,int price)
{
checkseat(seatNum);
for(int i=0;i<=seat.counter;i++)
{
if(set[seat.counter].available==true)
{
gameCode=gameCode;
set[seat.counter].number=seatNum;
set[seat.counter].category=categ;
set[seat.counter].price=price;
seat.counter++;
break;
}
else
{
System.out.println("is seat number is full");
}
}
}
public void checkseat(int num){
for(int i=0;i< set.length;i++)
{
if(set[i].number==num)
{
System.out.println("Seat is reserved");
set[i].available=false;
break;
}
}
}
the errors appeared:
Exception in thread "main" java.lang.NullPointerException
at sports.game.tickt.fans.checkseat(SportsGameTickt.java:199)
at sports.game.tickt.fans.reverseTicket(SportsGameTickt.java:170)
How can I fix that please?