Sale!

CSC/BIF 245 Assignment #1 Classes and Objects Solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (5 votes)

You are asked to write a program to manage books in a book store. The store has a collection of books. Each book has a title(of type String), an author(of type String), a number of pages(of type int), a genre (of type String) , number of copies (of type int) and a price(of type float). For this, the program should contain two classes Book and BookStore. The main method should be written in class BookStore. Some books are encyclopedias. These have an extra field number_of_volumes (of type int).

The program starts by displaying the following menu on the screen:

1.Add book
2.Delete book
3.Sell book
4.List all
5.Exit
———————-
Enter your choice:

The Add option – If the user inputs 1, the program prompts for the title of the book. If a book with a similar title exists, it prompts for the name of the author if the book is not a dictionary. If a book with the same author and same title exists, the number of copies is increased by 1 otherwise, the book is created and added to the collection in the book store.

The Delete option- If the user inputs 2, the program prompts for the title and the author of the book (if the book is not a dictionary) and removes the book if found in the collection. If the book is not found, an appropriate message is displayed.

The Sell book option – If the user inputs 3, the program prompts for the title and the author of the book, if the book is found, the number of copies is decreased by 1. If it reaches zero, the book is removed from the collection. If the book is not found, an appropriate message is displayed.
Here also, the program prompts for the author of the book only if the latter is not an encyclopedia.

The List all option – If the user enters 4, the information of all the books is displayed, one book per line. If the book is an encyclopedia, the letter “E” is displayed before the book information.

The Exit option- If the user chooses 5, the program terminates.

The menu is displayed again after each option except the Exit option which terminates the program.

Any choice from the menu other than 1,2, 3, 4 or 5 displays a message informing the user of the invalidity of the choice and prompts for it again.

There are two ways to end the program normally: either by having the user choose the Exit option or when an invalid choice is entered more than 5 consecutive times.

Notes:

• Override the method toString() in the appropriate classes. Use it!
• Implement method equals() and use it.
• You may assume that the user will always enter the correct type of data (i.e. integer numbers for number of copies, strings for titles, etc.).
• Following the good coding practice guidelines we have seen in class.
• Use casting only where necessary.

Plagiarism and cheating policy

Cheating is a serious offense. If a student is found to have copied part or all of the assignment, he or she will receive a zero on the assignment. During exams, if a student is caught cheating, he or she will receive a zero on the exam. This might result in the student getting an F on the course. NO EXCUSES WILL BE ACCEPTED. The same applies to the person providing others with material. The same applies to plagiarism (presenting someone else’s work as being one’s own work).

Deadline policy

Deadlines for submitting assignments will be announced in class or on the assignments. They are firm. Students must respect them. A student failing to meet the deadline will get 5% of the grade deducted per day late. A student cannot replace an assignment with another one. If he or she fails to submit an assignment, a zero will be scored on the missed assignment. To illustrate, if the student submits assignments 1 and 3 only, he or she will get a 0 on Assignment 2, Assignment 1 or 3 cannot compensate for the missed assignment.