Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is the code for the first part but i'm struggling with the second part. and would need help please (java) public class Book t

image text in transcribedimage text in transcribedimage text in transcribedthis is the code for the first part but i'm struggling with the second part. and would need help please (java)

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

public class Book t 20 21 23//initialize the four attributes 24 25 26 27 28 29// initiating parametrized constructor 30 31 32 String title; String author; long ISBN; double price; public Book (String t, String a, long isbn, double p) super) title - t; author a; ISBNisbn; price p; //increasing the object (book) count objectCount++; 34 35 36 37 38 39 40 41// accessors & mutators(setters&getters) 42 43 void setTitle(String t) title t; 45 46 47 48 49 50 51 52 53 54 String getTitle) return title; void setAuthor (String a) author a; 56 57 58 59 60 61 String getAuthor( return author 105 106 107 108 109 110 boolean equals (Book anotherBook) return ((ISBNanotherBook.getISBN)) && (priceanotherBook.getPrice())); 112 113 114 115 Part A book object has four attributes, a title (String), an author (String), an ISBN (long), and a price (double) For this part, you are required to design and implement the Book class according to the following specifications: Upon the creation of a book object, the object must immediately be initialized with valid values; that is title, author, ISBN and price. (Hint: Constructors.) The design should allow enough flexibility so that the value of any of these attributes can be modified later on. For example, it should be possible to create a book object with a given price then change its price later on. The design should also allow the user to obtain the value of any of the attributes (Hint: Accessors & Mutators.) Page 1 of 4 The design should allow all information of an object to be displayed at once through the utilization of System.out.print() method. (Hint: toString) method) It is required to know how many Book objects have been created. For that, you need to add a method, called findNumberOfCreatedBooks(), to the class. This method must return the number of created Book objects prior to the time this method is called. The method would simply return 0 if no books has been created by the time the method is called. (Hint: Static - You are allowed to add other attributes to the class.) It is required to compare two Book objects for equality. Two Book objects are considered equal if they have the same ISBN and price. (Hint: equals) method) - - It s required to display any Book object (all info of that object) using System.out.println() method. (Hint: toSting() method) ii. If the correct password is entered, ask the owner how many books s/he wants to enter Check that there is enough space in the bookstore (array of Book) to add these many books. If so, add them; otherwise inform the owner of the maximum remaining places in the array. (How the book information is input/entered by the user, is up to you) e. When option 2 is entered: i. Prompt the bookstore owner for his/her password. (Make sure you have a constant containing the password "password" as a constant - do not use another password) Again the bookstore owner has 3 attempts to enter the correct password. However, after the 3rd illegal entry, the main menu in figure 1 is simply re-displayed again (notice the different behaviour in that case from the previous one above) ll. Ask the user which book number s/he wishes to update. The book number is the index in the array inventory. If there is no Book object at the specified index location, display a message asking the user if he/she wishes to re-enter another book, or quit this operation and go back to the main menu. If the entered index has a valid book, display the current information of that book in the following format Book # X Author: name of author Title: title of book ISBN: isbn # Price: $price Then ask the user which attribute they wish to change by displaying the following menu. What information would you like to change? 1. author 2. title 3. ISBN Fig 2. Update menu uit Enter your choice> Once the user has entered a correct choice, make the changes to the attribute then display again all of the attributes on the screen to show that the attribute has been changed. Keep prompting the user for additional changes until the user enters 5. Each time the user is prompted for a choice make sure that a number from 1 to 5 is entered, otherwise keep prompting until a valid number is entered f. When option 3 (in the main menu shown in Fig. 1) is entered, prompt the user to enter an author name. You then need to display the information of all books by that requested author. (Hint: You may use a static method, for instance called findBooksBy , which accepts a string for an author name then performs the needed search) g. When option 4 (in the main menu shown in Fig. 1) is entered, promtp the user to enter a value (representing a price). You them need to display all books that have a vlaue smaller than that entered value. (Hint: You may use a static method, for instance called indCheaperThan, which accepts a double value, for a price, then performs the needed search) Page 3 of 4 h. When option 5 (in the main menu shown in Fig. 1) is entered, display a closing message and end the driver

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

Which are non projected Teaching aids in advance learning system?

Answered: 1 week ago