Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Esier task to do a small library that take informations from objects

Would love some help with my program. I got an esier task in witch i have to create an esier library that had a class objects and getter/setter methods. My goal was to with anArray list create objects in from of books with ibn nr and author name but got into quite a problem now. I want with help of inputs be able to search for the objects aswell and print them out. I dont know if this is on the right way and would love some help.

import java.util.Scanner;

import java.util.ArrayList;

public class JAVA extends LIBRARY { private String author;

public JAVA(String Name, long ISBN) {
    super(Name, ISBN);
    this.author = author;

}


public static void main(String[] args) {
    JAVA myAPP = new JAVA();
    Scanner scan = new Scanner(System.in);
    ArrayList<LIBRARY> persons = new ArrayList();
    persons.add(new LIBRARY("Harry Potter", 111111));
    persons.add(new LIBRARY("Sagan om ringen", 222222));
    persons.add(new LIBRARY("Pet Cemetary", 333333));

    int LÖS = 1;
    int input;


    System.out.println("Välkommen till Hkr Biblotek!");
    System.out.println("Tryck 1 för att söka böcker 2 för att avsluta");
    input = scan.nextInt();
    if (LÖS == 1) {




        myAPP.inputBok(input);
    } else if (LÖS > 1) {
        System.exit(2);
    }


}

public String inputBok(int a) {
    Scanner scan = new Scanner(System.in);
    String input;
    long input1;
    System.out.println("Skriv in bokens namn!");
    switch (scan.nextInt()) {

        case 1:


            input = scan.nextLine();

        case 2:

            System.out.println("Skriv in bokens ISBN nummer!");
            input1 = scan.nextLong();
        case 3:
            System.out.println("Denna bok kostar");
            System.out.println("Det finns även böcker med liknade titlar");

    }
    return inputBok(a);

}

} public class LIBRARY {

public final long ISBN;
public final String NAME;


public LIBRARY(String Name, long ISBN) {
    this.NAME = Name;
    this.ISBN = ISBN;

}

public String getNAME() {
    return NAME;
}

public long getISBN() {
    return ISBN;


}

public String toString() {
    return "LIBRARY{" + NAME + ISBN;


}

}