COSC2391 Further Programming/COSC1295 Advanced Programming
Assignment 1 – Semester 2 2024
Introduction
You are required to implement a basic Java program using Java. This assignment is designed to:
• Test your knowledge of basic Java concepts.
• Evaluate your ability to design programming logic.
• Practice simple object design in Java.
This is an individual assignment. Your final submission is worth 15%; a simple demo in Week 4 is worth a further 3%, giving a total of 18% for Assignment 1.
Academic Integrity (more)
The submitted assignment must be your own work. No marks will be awarded for any work which is not created by you.
Plagiarism is treated very seriously at RMIT. Plagiarism includes copying code directly from other students (or enables such copying), the internet, the output of AI systems, or other resources without proper reference. Sometimes, students’ study and work on assignments together and submit similar files which may be regarded as plagiarism. Please note that y ou should always create your own assignment even if you have very similar ideas. Plagiarism-detection tools will be used to check all submissions. Penalties may be applied in cases of plagiarism.
The Reading Room Book Shop
You are to implement a book purchasing system, called “The Reading Room” . The system keeps a list of books that can be purchased (in physical and/or ebook form) as follows.
• Each book has limited number of physical copies. You will track the number of available physical copies of each book. If the user tries to buy a (physical) book and there are no copies available, then the system outputs an error message.
• Some (not all) books are available in ebook form. There is no limit of copies for ebooks. If the ebook exists for a book, then there is always a copy of the ebook available.
• All physical books cost $50.00; all ebooks cost $8.00.
• The user can request purchasing a book by specifying a keyword: the system lists all books that contain the keyword, along with the number of copies and ebook availability. The user chooses which form. of the book they want: if the book is available then it gets added to the user’s “shopping cart” . Note that keyword matching is not case-sensitive here.
• The user can view and update the shopping cart.
• The user can print the full list of books and their availability.
• Once the user is finished selecting books, the user can “checkout and pay”; the system prints the final total price and updates the number of copies of each book.
• The user can quit the system (before or after paying).
Assumptions and Simplifications.
1. All prices as per Australian currency denominations.
2. Correct input can be assumed in this assignment. Error handling is not required.
Part A
Implement the above specifications without necessarily using object-oriented design at this stage. The key focus is to implement the correct algorithm logic. You can implement the system in one main program in a single class (Note: you may skip Part A and go straight to Part B with the use of OO. Part A is designed to let you focus on the basic functionalities.)
Following is a possible sample interaction with the bookstore system. You do not have to strictly follow the format but it illustrates required functionality. Text in bold and green is input from the user:
=============================================== Welcome to The Reading Room!
===============================================
Choose an option:
1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
6. Quit
Please select: 1
Enter a keyword: Java concepts
Sorry! There are no books that match with your key word.
Choose an option:
1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
6. Quit
Please select: 1
Enter a keyword: java
The following book (s) are found:
1. Absolute Java
2. JAVA: How to program
3. Computing Concepts with Java 8 Essentials
4. Java Software Solutions
5. Java Program Design
6. Cancel
Please select: 2
Do you want to buy this as an ebook: no
Sorry! There are no physical copies of the book!
Choose an option:
1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
6. Quit
Please select: 1
Enter a keyword: Computing
The following books are found:
1. Computing Concepts with JAVA 8 Essentials
2. Cancel
Please select: 1
Do you want to buy this as an ebook: no
“Computing Concepts with JAVA 8 Essentials” has been added to your cart.
Choose an option:
1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
6. Quit
Please select: 2
Your shopping cart contains the following book (s):
1. Computing Concepts with JAVA 8 Essentials
Choose an option:
1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
6. Quit
Please select: 3
Your shopping cart contains the following book (s):
1. Computing Concepts with JAVA 8 Essentials
2. Cancel
What do you want to remove: 1
Item removed from shopping cart
Choose an option:
1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
6. Quit
Please select: 1
Enter a keyword: Absolute
The following book (s) are found:
1. Absolute Java
2. Cancel
Please select: 1
Do you want to buy this as an ebook: no
“Absolute Java” has been added to your cart.
Choose an option:
1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
6. Quit
Please select: 4
You have purchased items to the total value of $50.00. Thanks for shopping with The Reading Room!
Choose an option:
1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
6. Quit
Please select: 5
The following books are available:
1. Absolute Java, 4 copies, ebook available
2. JAVA: How to Program, 0 copies, ebook available
3. Computing Concepts with JAVA 3 Essentials, 5 copies, no ebook
4. Java Software Solutions, 5 copies, no ebook
5. Java Program Design, 1 copy, ebook available
Choose an option:
1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
6. Quit
Please select: 6 Goodbye!
Part B
The aim of Part B is to incorporate basic object-oriented concepts into your program and test main
functionality. In particular, define a Book class that contains all information related to a book title, including the title, author (this is new!), number of physical copies, and ebook availability. Using the OO solution, you should only use ONE ARRAY---an array of Book objects.
The only change to the functionality is that when you print list of books, you list both title and author, as well as number of copies and ebook availability (see example output below).
NOTE1: it is OK to start using Object Oriented concepts from the start of the assignment if you prefer--- i.e. it is not a requirement to complete Part A before introducing OO.
===============================================
Welcome to The Reading Room!
===============================================
Choose an option:
1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
6. Quit
Please select: 1
Enter a keyword: Java
The following book (s) are found:
1. Absolute Java | Savitch | 5 copies | yes
2. JAVA: How to program | Deitel and Deitel | 0 | yes
3. Computing Concepts with JAVA 8 Essentials | Horstman | 5 | no
4. Java Software Solutions | Lewis and Loftus | 5 | no
5. Java Program Design | Cohoon and Davidson | 1 | yes
6. Cancel
Please select: 2
Do you want to buy this as an ebook: no
Sorry! There are no physical copies of the book!
Choose an option:
1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
6. Quit
Please select: 5
The following books are available:
1. Absolute Java | Savitch | 5 copies | yes
2. JAVA: How to program | Deitel and Deitel | 0 | yes
3. Computing Concepts with JAVA 8 Essentials | Horstman | 5 | no
4. Java Software Solutions | Lewis and Loftus | 5 | no
5. Java Program Design | Cohoon and Davidson | 1 | yes