CSCI 2003 Programming Assignment 4 website of a pet store solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

Objectives:
 Practice implementing classes
 Practice if/else and if/else if/else statements
 Practice printf
Assignment:
For this assignment, you are going to simulate the website of a pet store that helps the user choose a dog to
adopt. You will need 2 separate files: one for the Dog class and one for the PetStore class.
Dog Class
This class will simulate a dog. This class stores the size and coat length of a dog and determines the breed based
on those two attributes.
You will need 2 instance variables for:
 Size of the dog – String datatype
 Length of the dog’s coat – String datatype
You will need to include an argument constructor and a no-argument constructor to initialize the instance
variables.
You will need a getter and setter to access each of the instance variables (4 methods total).
You will need a method that determines and returns the breed of the dog based on the values of the two instance
variables. The breed is NOT stored in an instance variable. DO NOT use multiple if statements. The table
shows the attributes determine the breed:
Breed Size Coat Length
Pug Small Short
Shiba Inu Small Medium
Cocker Spaniel Small Long
Basset Hound Medium Short
Gordon Setter Medium Medium
Irish Setter Medium Long
Weimaraner Large Short
Goldendoodle Large Medium
Belgian Sheepdog Large Long
2
PetStore Class
This class will use the Dog class to simulate an order from the PetStore website.
You will need to create 1 object of the Dog class.
The program will greet the customer and display the prices for the dogs based on size. Next, display the
different sizes of dogs available, and ask the user to choose one. Next, display the different coat lengths of the
dogs available, and ask the user to choose one. Based on the user’s input set the correct values to the objects
variables. DO NOT use multiple if statements.
Once the objects values are set, display the dog that matches with the size and coat length chosen. You must use
the method that determines breed from the Dog class. Then, ask the user if they would like to adopt the dog.
They will enter ‘y’ or ‘n’.
If they enter ‘y’, display the receipt and display the farewell message as seen in the sample execution. If they
enter ‘n’, just display the farewell message.
You don’t have to include error checking.
3
Sample Execution:
PetStore Class Output 1:
Welcome! Select traits to choose a dog!
=======================================
======================
| AVAILABLE PRICES |
======================
Small Dog —– $40.00
Medium Dog —- $60.00
Large Dog —– $80.00
Sizes
=========
1. Small
2. Medium
3. Large
Enter choice (1, 2, or 3): 3
Coats
=========
1. Short
2. Medium
3. Long
Enter choice(1, 2, or 3): 3
Based on your responses, we suggest a Belgian Sheepdog!
Would you like to adopt a Belgian Sheepdog for $80.00? (y/n): y
Breed: Belgian Sheepdog
—————————
Subtotal: $80.00
Tax: $ 8.80
Total: $88.80
Please come again!
4
PetStore Class Output 2:
Welcome! Select traits to choose a dog!
=======================================
======================
| AVAILABLE PRICES |
======================
Small Dog —– $40.00
Medium Dog —- $60.00
Large Dog —– $80.00
Sizes
=========
1. Small
2. Medium
3. Large
Enter choice (1, 2, or 3): 1
Coats
=========
1. Short
2. Medium
3. Long
Enter choice(1, 2, or 3): 1
Based on your responses, we suggest a Pug!
Would you like to adopt a Pug for $40.00? (y/n): y
Breed: Pug
—————————
Subtotal: $40.00
Tax: $ 4.40
Total: $44.40
Please come again!
5
PetStore Class Output 3:
Welcome! Select traits to choose a dog!
=======================================
======================
| AVAILABLE PRICES |
======================
Small Dog —– $40.00
Medium Dog —- $60.00
Large Dog —– $80.00
Sizes
=========
1. Small
2. Medium
3. Large
Enter choice (1, 2, or 3): 2
Coats
=========
1. Short
2. Medium
3. Long
Enter choice(1, 2, or 3): 2
Based on your responses, we suggest a Gordon Setter!
Would you like to adopt a Gordon Setter for $60.00? (y/n): n
Please come again!
6
Requirements:
 Use an updated comment block
 Your program should use the following comment block at the very beginning of your program.
// Name: Your Name Date Assigned: Fill in
//
// Course: CSCI 2003 60357 Date Due: Fill in
//
// Instructor: Ms. Greer
//
// File name: Fill in
//
// Program Description: Brief description of what the program does.
 Use appropriate comments throughout the program
 Make good use of whitespace
 Your output should look exactly like the sample output if using the same data.
Deliverables:
 Dog.java file
 PetStore.java file
 Upload 2 files to Moodle
Grading:
Total Points 15 points
Dog Class 7 points
Declare instance variables correctly 1 point
Constructors are correct 1 point
Getters and setters are correct 1 point
Method that determines breed is correct 4 points
Correctly determines the breed 1 point
Uses the instance variables for size and coat 1 point
Returns the breed 1 point
Uses the correct decision structure 1 point
PetStore Class 8 points
Displays prices, sizes, and coats options correctly 0.5 point
Creates 1 object 1 point
Gets user input for size and coat correctly 1 point
Uses correct decision structure to determine actual size and coat 1 point
Correctly sets instance variables based on user input 1 point
Displays pet and asks user if they want to adopt pet 0.5 point
Uses decision structure to determine if they will adopt 1 point
Displays receipt correctly if user wants to adopt, then farewell 1 point
Displays farewell message only if user doesn’t want to adopt 1 point
Not enough comments/whitespace -1 point
Output does not match the sample executions given in the
assignment
-1 point
Bad variable names, method names, and/or class names -1 point