Bunch of errors that aren't valid, probably because of formatting but I can't crack it

52 Views Asked by At
public class TicketTest
{
    int serial;
    
    public static void main(String args[])
    {
        int total_sales = 0;
                new WebTicket(10);
                new WebTicket(5);
                new CounterTicket();
                new DiscountTicket(5, "Student");
                new DiscountTicket(10, "Senior");
        
        
    }
}

class Ticket(int days, String type) {
    public static int COUNTER_TICKET_PRICE = 50; 
    public static int WEB_TICKET_PRICE = 30; 
    public static int WEB_TICKET_LT_WEEK_PRICE = 40; 
    public static double DISCOUNT = 0.5;
    int serial;
    int price;
}
class WebTicket extends Ticket {
    if (days>7) {
        price = 40;
    }else {
        price = 30;
    }
    System.out.println("Ticket: [serial= "+serial+" Price: "+price+"]");
    serial += 1;
}
class CounterTicket extends Ticket {
    price = 50;
    System.out.println("Ticket: [serial= "+serial+" Price: "+price+"]");
    serial += 1;
}
class DiscountTicket extends Ticket {
    if (days>7) {
        price = 20;
    }else {
        price = 15;
    }
    System.out.println("Ticket: [serial= "+serial+" Price: "+price+" Type: "+type+"]");
    serial += 1;
}

I'm trying to make a program that prints ticket info when those classes in the main method are called, but the "class" in class Ticket is getting and error saying a record is expected and the new __Ticket things in the main method aren't being recognized.

Console looks like this:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    Syntax error, insert ". class" to complete Expression
    tickets cannot be resolved to a variable
    tickets cannot be resolved to a variable
    tickets cannot be resolved to a variable
    tickets cannot be resolved to a variable

    at test.TicketTest.main(TicketTest.java:12)

I tried to delete/add curly braces where I could but to no avail. It's probably a typo or something that I can't find.

1

There are 1 best solutions below

0
Corrupted_RainbowGuy On

@TrippKinetics Yeah, that was my problem. I had to make functions inside of the classes to make constructors to call, and I was trying to pass params in classes. Thanks!