-3

I keep getting a compilation error that I can't figure out how to debug.

public class AdvanceTicket extends Ticket implements ITicket {
    int number;
    int NumDays;
    double price = 40.0;
   
    public AdvanceTicket(int number, int days) 
    {
        this.number = number;
        this.NumDays = days;
    }

for some reason, this breaks the code right above here

    public AdvanceTicket() {

    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int ticketNumber) {
        this.number = number;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getDays() {
        return NumDays;
    }

    public void setDays(int days) {
        NumDays = days;
    }

    public String toString() {

        if (this.getDays() > 10)
            this.setPrice(30.0);

    return "Number: " + this.getNumber() + " Price: " + 
    this.getPrice() + " Purchased " + this.getDays() + " days before 
    event";
        }
    }
}
AdvanceTicket.java:8: error: constructor Ticket in class Ticket 
cannot be applied to given types;
{
^
  required: int
  found:    no arguments
  reason: actual and formal argument lists differ in length

I don't understand how this error is happening, could anyone help? I have the exact same code in other classes pretty much, and that code works. I've looked into compiler errors and this seems to be wacko and not covered at all...

John Kugelman
  • 330,190
  • 66
  • 504
  • 555
Gordo
  • 1
  • 2

1 Answers1

-1

The Ticket class evidently defines a constructor that takes one argument and not one that takes zero. You need to make a super call to the parent constructor.

Silvio Mayolo
  • 41,871
  • 4
  • 57
  • 86