import java.util.Arrays; import java.util.Scanner; public class ReadBooks { public static void main(String[] args) { // Don't change Scanner input = new Scanner(System.in); Book[] books = new Book[2]; // Fill the array with books whom information has been input by user for (int n = 0; n < books.length; n++) { System.out.print("Titel> "); input.nextLine(); System.out.print("Inbunden (J/N)> "); input.nextLine(); } // Don't change System.out.println(Arrays.toString(books)); input.close(); } } // No need to change class Book { String title; boolean bound; Book(String title, boolean bound) { this.title = title; this.bound = bound; } public int getPrice() { return bound ? 300 : 100; } @Override public String toString() { return title + " " + getPrice() + " " + bound; } }
books[n] = bk;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)