java代写-COSC2391-Assignment 1
时间:2021-03-24
COSC2391 Further Programming
School of Computing Technologies, RMIT University
Assignment 1 – Semester 1 2021

Due date: 11:59pm, March 29, 2021

Introduction
You are required to implement a basic Java program using Java SE 8.0
or 11.0
This assignment is designed to:
• Test your knowledge of OO basic and Java
basic concepts;
• Evaluate your ability to design
programming logic;
• Practise simple object design in Java.
This is an individual assignment and worth 10% towards your final grade.

Task Specification
You are to implement a book purchasing system, called Daintree. The system keeps a list of
book titles that can be purchased, in both physical and ebook form.
You have to keep track of how many copies of the physical books are available for each
title. 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) titles are available in ebook form. If the ebook exists for that title, 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 giving the starting part of the title: the
system then lists all books that start with that string, along with the number of copies and
ebook availability. The user enters which form of the book they want: if the book is
available then it gets added to the user’s “shopping cart”.
o Matching for titles is not case-senstive.
Once the user is finished selecting books, they “checkout and pay”; the system prints the
final total price, and updates the number of copies of each book.
The user has the option of viewing their shopping cart and removing books.
The user has the option of printing the full list of books and their availability.
The user can quit the system (before or after paying).
Part A (5%)
Implement the above specifications. You do not have to use object oriented concepts at this
point---just implement the system in a main program in a single class. (You should use
multiple methods to break up the complexity of your code---don’t put it all in one method!!).

SIMPLIFICATIONS for Part A:
when the user searches for a book, only the first match is displayed;
the Shopping Cart can only hold one book (any further choices replace it).
HINTS:
1. One way to manage books is to use 3 arrays:
a. array of String that stores the titles;
b. array of int that is the number of physical copies of the title at that index;
c. array of boolean that is the availability of ebook of the title at that index.
2. the String methods startsWith() and toUpperCase()/toLowerCase()will
probably be useful.

The system should present a menu with the following options:

1. Add a book to shopping cart
2. View shopping cart
3. Remove a book from shopping cart
4. Checkout
5. List all books
0. Quit

Option 1 should query for the title to purchase and display all titles that start with what the
user types, along with the number of copies and ebook availability.
If there are no matches then an error is printed.
An error is printed if the type (physical or ebook) the user requests is not available.


Book titles to include as data:
You must include the following titles as a minimum exactly as written below, for testing
purposes (authors are provided for use in Part B). Number of items in stock and ebook
availability are indicated. For this assignment, hand-code these titles directly into your arrays:




General Requirements
You programs should perform basic input validation---e.g., you should check that
selected options are not out-of-bounds.
You had frequent push into Github classroom.
All programs should be written, compile and run on Codingrooms.
There will be marks allocated for following good coding style, proper commenting of
your code, consistent indentation, not “hard-coding” fixed values or assumptions, etc.
Absolute Java (Savitch) 5 yes
JAVA: How to Program (Deitel and Deitel) 0 yes
Computing Concepts with JAVA 8 Essentials (Horstman) 5 no
Java Software Solutions (Lewis and Loftus) 5 no
Java Program Design (Cohoon and Davidson) 1 yes

Following is a possible sample interaction with the Daintree bookstore system. (You do not
have to follow this precisely but it illustrates required functionality.)
Text in bold would be input from the user:

Welcome to Daintree!
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
0. Quit
Please make a selection: 1

Enter title to search for: Java concepts
There is no title starting with that


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
0. Quit
Please make a selection: 1

Enter title to search for: Java
The following title is a match:
1. JAVA: How to program
0. cancel
What is your selection: 1
Do you want to buy this as an ebook: no
There are no physical copies of that book 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
0. Quit
Please make a selection: 1

Enter title to search for: Computing
The following title is a match:
1. Computing Concepts with JAVA 8 Essentials
0. cancel
What is your selection: 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
0. Quit
Please make a selection: 2

Your Shopping Cart contains the following:
1. Computing Concepts with JAVA 3 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
0. Quit

Please make a selection: 3

Your Shopping Cart contains the following:
1. JAVA: How to program
0. 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
0. Quit
Please make a selection: 1

Enter title to search for: Absolute
The following title is a match:
1. Absolute Java
0. cancel
What is your selection: 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
0. Quit
Please make a selection: 4

You have purchased items to the total value of $30.00
Thanks for shopping with Daintree!


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
0. Quit
1.
Please make a selection: 5

The following titles are available:
2. Absolute Java, 4 copies, no ebook
3. JAVA: How to Program, 0 copies, ebook available
4. Computing Concepts with JAVA 3 Essentials, 5 copies, no ebook
5. Java Software Solutions, 5 copies, no ebook
6. 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
0. Quit
Please make a selection: 8
Sorry, that is an invalid option!
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
0. Quit
Please make a selection: 0

Goodbye!


Part B (2%)
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. Your main program should be in a new BookStore class. 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 in Part C).

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.

NOTE2: Write at least 3 Unit tests for your main function.
Part C (3%) (don’t do this until after Part B)
Extend your solution so that:
All matches to a search is displayed and the user selects using number. An error is
printed if the user selects an invalid line number, and the system prompts for a new
line number. There should also be a “cancel” option.
The Shopping Cart can hold as many items as are
selected. Selecting an item to remove should work as
above.
Write Unit Test for all classes that include functions. Each function should have
at least 2 test cases.
To implement this extension, you need to use more arrays (for selection and Shopping Cart).
This extension would result in the following changes to the above interaction:
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
0. Quit
Please make a selection: 1

Enter title to search for: Java
The following title is a match:
1. JAVA: How to program -- Deitel and Deitel
2. Java Software Solutions -- Lewis and Loftus
3. Java Program Design -- Cohoon and Davidson
0. cancel
Which number item do you wish to purchase: 1
Purchasing: JAVA: How to program
Do you want to buy this as an ebook: no
There is no ebook available for that title

If you had 2 items in your Shopping Cart, then removing an item would look like this:

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
0. Quit
Please make a selection: 3

Your Shopping Cart contains the following:
1. JAVA: How to program
2. Absolute Java
0. cancel
Which number item do you wish to remove: 1
Selected: JAVA: How to program
Do you want to remove it: yes
Item removed from Shopping Cart



























































































































































































































































































































学霸联盟


essay、essay代写