I need to make a class that records some information for a book. I need to make 2 constractors, the 1st one receives 6 "elements" and 2nd one only the first 5, as you can see in the code below. I also need to make a simple main program to check if it's working. I've been having errors though, I need help.
The class I made is the following:

public class LibraryRecord extends MainErgasia{
    private String title;
    private String writer;
    private int Lnumber;
    private String publisher;
    private int year;
    private boolean release;



    public LibraryRecord(String title,String writer,int Lnumber,String publisher, int year, boolean release){
        BookTitle = title;
        BookWriter = writer;
        LibraryNumber = Lnumber;
        BookPublisher = publisher;
        BookYear = year;
        BookRelease = release;
    }
    public LibraryRecord (String title,String writer,int Lnumber,String publisher, int year){
        BookTitle = title;
        BookWriter = writer;
        LibraryNumber = Lnumber;
        BookPublisher = publisher;
        BookYear = year;
        BookReleased = released;
    }
    public String getTitle(){
        return BookTitle;
    }
    public String getWriter(){
        return BookWriter;
    }
    public int getLNumber(){
        return LibraryNumber;
    }
    public String getPublisher(){
        return BookPublisher;
    }
    public int getYear(){
        return BookYear;
    }
    public void setReleased(boolean flag){
        released = flag;
    }
    public boolean isReleased(){
        return released;
    }
    public String toString(){
        return BookWriter + "(#"+ LibraryNumber +")";
    }

}

The main program is the following:

public class main extends Program{

    LibraryRecord topBook = new LibraryRecord ("Hunger Games", "S.Collins",9780, "Press" , 2008,topBook.setReleased());
    LibraryRecord topBook = new LibraryRecord ("Hunger games", "S.Collins",9780, "Press",2008);


    LibraryRecord obj=topBook;
    println(obj);

}

Saying what the errors are is useful. That said, you are assigning your arguments to variables with the wrong variable names in your constructors such as BookTitle when the variable name for the class is 'title'. So, in the class, your variables should be things like BookTitle, ... BookReleased, etc.

Here's the link with the errors I get when I try to run the MainErgasia(Main program): http://prntscr.com/9g0g37

Saying what the errors are is useful. That said, you are assigning your arguments to variables with the wrong variable names in your constructors such as BookTitle when the variable name for the class is 'title'. So, in the class, your variables should be things like BookTitle, ... BookReleased, etc.
But I did " BookTitle = title; " etc in the code I wrote. So, it should be okay?

No
You use names like BookTitle, but you never declare any variables with those names. Everything in Java must be declared.
In your constructor you should initialise the variables you declared on lines 2-7

public class LibraryRecord{
    private String title;
    private String writer;
    private int Lnumber;
    private String publisher;
    private int year;
    private boolean release;



    public LibraryRecord(String title,String writer,int Lnumber,String publisher, int year, boolean release){
        this.title = title;
        this.writer = writer;
        this.Lnumber = Lnumber;
        this.publisher = publisher;
        this.year = year;
        this.release = release;
    }
    public LibraryRecord (String title,String writer,int Lnumber,String publisher, int year){
        this.title = title;
        this.writer = writer;
        this.Lnumber = Lnumber;
        this.publisher = publisher;
        this.year = year;
        this.release = release;

    }
    public String getTitle(){
        return title;
    }
    public String getWriter(){
        return writer;
    }
    public int getLNumber(){
        return Lnumber;
    }
    public String getPublisher(){
        return publisher;
    }
    public int getYear(){
        return year;
    }
    public void setRelease(boolean flag){
        release = flag;
    }
    public boolean isRelease(){
        return release;
    }
    public String toString(){
        return writer + "(#"+ Lnumber +")";
    }

}

I changed my code of the class to this one (above) and I compiled it and I have no errors. Now I go to my main program:

import acm.program.*;

public class MainErgasia extends Program{
    public void run(){
    LibraryRecord hungergames = new LibraryRecord ("Hunger Games", "Collins", "9780", "Scholarship Press", "2008");

    println(hungergames);
    }

}

And I get the following errors: 


MainErgasia.java:5: error: cannot find symbol
        LibraryRecord hungergames = new LibraryRecord ("Hunger Games", "Collins", "9780", "Scholarship Press", "2008");
        ^
  symbol:   class LibraryRecord
  location: class MainErgasia

MainErgasia.java:5: error: cannot find symbol
        LibraryRecord hungergames = new LibraryRecord ("Hunger Games", "Collins", "9780", "Scholarship Press", "2008");
                                        ^
  symbol:   class LibraryRecord
  location: class MainErgasia
2 errors

Your constructors are defined as having some String and some int parameters., but when you call the constructors you just pass a lot of Strings.

Ie: the compiler is looking for a constructor that can accept parameters (String, String, String, String, String), but all it finds is constructors that take (String, String, int, String, int)

Yes, I fixed that already and I still get the following errors:

MainProgram.java:5: error: cannot find symbol
        LibraryRecord hungergames = new LibraryRecord ("Hunger Games", "Collins", 9780, "Scholarship Press", 2008);
        ^
  symbol:   class LibraryRecord
  location: class MainProgram

MainProgram.java:5: error: cannot find symbol
        LibraryRecord hungergames = new LibraryRecord ("Hunger Games", "Collins", 9780, "Scholarship Press", 2008);
                                        ^
  symbol:   class LibraryRecord
  location: class MainProgram
2 errors

That looks like the LibraryRecord class is not visible from the MainErgasia class. That's possibly something to do with the directory structure where they are held.
Unless you are using any package stateents, make sure both .java files are in the same directory, and ditto the two .class files. The directory where the .class files are stored should be in your classpath.

I've got them into the same file.. So, no package needed. :/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.