Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part I ) A book object has four attributes, a title ( String ) , an author ( String ) , an ISBN ( long
Part I 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.
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 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 is required to display any Book object all info of that object using System.out.println method. Hint: toSting method
Part II You are hired by a bookstore to write a software that helps the store owner in keeping track of the books at the store. Write a driver program that will contain, at least, the following methods. Note: You can have the main function in a separate driver file, or in the same file if you prefer. a main method, that will: a Display a welcome message b Prompt the bookstore owner for the maximum number of books maxBooks hisher bookstore can contain. Create an empty array, called inventory, that will have the potential of keeping track of the created Book objects. c Display a main menu fig with the following choices and keep prompting the user until they enter a number between and inclusive: d When option is entered: i Prompt the bookstore owner for hisher password. Make sure you have a constant variable containing the password password do not use any other password as it will be easier for the marker to check your assignments The bookstore owner has a maximum of attempts to enter the correct password. After the rd illegal entry, the main menu in figure is redisplayed again. Additionally after this process is repeated times ie total failed attemopts is by now the program must displays the following messages: Program detected suspicous activities and will terminate immediately! then the program must exits.
What do you want to do Enter new books password required Change information of a book password required Display all books by a specific author Display all books under a certain a price. Quit Please enter your choice
ii If the correct password is entered, ask the owner how many books she 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 inputentered by the user, is up to you e When option is entered : i Prompt the bookstore owner for hisher password. Make sure you have a constant containing the password password as a constant do not use another password Again the bookstore owner has attempts to enter the correct password. However, after the rd illegal entry, the main menu in figure is simply redisplayed again notice the different behaviour in that case from the previous one above ii Ask the user which book number she 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 heshe wishes to reenter 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? author title ISBN price Quit 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 Each time the user is prompted for a choice make sure that a numb
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started