programming

gurvir sidhu
CPSC1012Assignment4-Fall2021Term-Version211.pdf

CPSC1012 Assignment 4 – Fall 2021 Term

CPSC1012 Assignment 4 – Object-Oriented Programming Weight: 20% of your final mark Late submissions will not be marked.

Program Specifications A veterinarian friend of yours has expressed interest in having program made to help them manage their clinic. Being that you have some programming skill, you have offered to create a pilot program for the veterinarian as a proof of concept with the hopes that you will be contracted to create the clinic’s entire system. Currently, the clinic sees a lot of dogs and cats that require one of two specific medications: Acepromazine and Carprofen. As a pilot project, you will create a program that will help track the administration of these two drugs to the pets that are brought in. The program build will be developed in two parts: Part A – Class and Object Implementation Pet Class Design a class named Pet that meets the following requirements:

• A string property named Name for the pet (default value is “Spot”). o The mutator for Name will check if the new value contains at least one nonwhitespace

character otherwise it will throw an exception. • An int property named Age in years for the pet (default value is 1).

o The mutator for Age will check if the new value is one (1) or greater before using the new value otherwise it will throw an exception.

• A double property named Weight in pounds for the pet (default value is 5). o The mutator for Weight will check if the new value is five (5) or greater before using the

new value otherwise it will throw an exception. • A string property named Type that indicates if the type of pet is a dog or a cat (default is D for

Dog). o The mutator for Type will check if the new value is D or C before using the new value

otherwise it will throw an exception. o The accessor for Type will return the string literal Dog if the type is D otherwise it will

return the string literal Cat. • A no-argument constructor that creates a default pet. • A constructor that creates a pet with a specified name, age, weight, and type. • A method named Acepromazine() that returns as a double the dosage in ml for the sedative

acepromazine. • A method named Carprofen() that returns as a double the dosage in ml for the pain killer

carprofen.

The dosage calculation is:

𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 (𝑚𝑚𝑚𝑚) = 𝑊𝑊𝐷𝐷𝑊𝑊𝐷𝐷ℎ𝑡𝑡 ∗ 𝑚𝑚𝐷𝐷 𝑝𝑝𝐷𝐷𝑝𝑝 𝑘𝑘𝐷𝐷 𝑚𝑚𝑝𝑝𝐷𝐷 𝑝𝑝𝐷𝐷𝑝𝑝 𝑚𝑚𝑚𝑚

NOTE: Weight is in kg • For acepromazine, use mg per ml = 10, and mg per kg = 0.03 for dogs and 0.002 for cats. • For carprofen, use mg per ml = 12, and mg per kg = 0.5 for dogs and 0.25 for cats.

CPSC1012 Assignment 4 – Fall 2021 Term

Write a program to test your Pet class as shown in the sample run:

|---------------------| | CPSC1012 Pet Clinic | |---------------------| Enter the name of your pet: Bob Enter the age in years of your pet: 10 Enter the weight in pounds of your pet: 60 Enter D for Dog, C for Cat: D Name: Bob, Age: 10 years, Weight: 60 lb, Type: Dog Is the information above your pet, correct? Enter y or n: y Service Options: 1. Pain Killer 2. Sedative 3. Both Pain Killer and Sedative Enter the service (1-3) required for your pet: 3 Your pet requires 1.134ml of carprofen. Your pet requires 0.082ml of acepromazine. Do you have another pet that requires service? Enter y or n: Y |---------------------| | CPSC1012 Pet Clinic | |---------------------| Enter the name of your pet: Invalid input value. A pet name is required and must contain at least one character. Enter the name of your pet: Fritz Enter the age in years of your pet: 0 Invalid input value. Age must be at least 1 years old. Enter the age in years of your pet: 3 Enter the weight in pounds of your pet: 1 Invalid input value. Weight must be at least 5 pounds. Enter the weight in pounds of your pet: 10 Enter D for Dog, C for Cat: Z Invalid input value. Pet type must be D or C. Enter D for Dog, C for Cat: C Name: Fritz, Age: 3 years, Weight: 10 lb, Type: Cat Is the information above your pet, correct? Enter y or n: Y Service Options: 1. Pain Killer 2. Sedative 3. Both Pain Killer and Sedative Enter the service (1-3) required for your pet: 1 Your pet requires 0.094ml of carprofen. Do you have another pet that requires service? Enter y or n: n Good-bye and thanks for coming to the Pet Clinic.

CPSC1012 Assignment 4 – Fall 2021 Term

Part B – Pet List Implementation Improve on the program developed in Part A by adding the following features:

• The program should make use of a ‘database’ (i.e.. CSV file) to store pets o The ordering of fields for the CSV file is up to you, ensure that it is an acceptable format

• Read the file into the system when the program begins o Load each pet from the file as a Pet object and store the Pet objects in a List

• Allow the user to search for an existing pet in the system in addition to being able to add a new Pet

o Add the ability to remove pets from the system • The ‘database’ file must keep accurate records for the system

o Any new pet additions to the system must be added to the List of Pets o Any pets removed from the system must be removed from the List of Pets o Write the List of Pets to the file when the program ends

Coding Requirements (these requirements are expected, and you will not receive corrective feedback prior to the submission deadline if any of the following are unmet)

• A C# comment block at the beginning of the source file describing the purpose, input, algorithm, output, author, last modified date of the program

• All methods must be properly documented and commented • Write only one statement per line. • Use camelCase for local variable names. • Use PascalCase for any constant variable names • Use defensive programming where necessary • Ensure graceful handling of exceptions (i.e. your program must not crash)

Aside from what’s been presented in this document, do not make any assumptions. Seek clarity from your instructor if you do not understand something in this document.

CPSC1012 Assignment 4 – Fall 2021 Term

Evaluation [20 marks total] Marking Rubric [Part A - Class and Object Implementation]

Mark Description 10 Excellent – Pet class is properly defined: proper member variables (visibility, names, and

types); proper member methods/properties (visibility, correct implementation, return correct values); both constructor methods are correctly defined; Pet objects correctly instantiated and used in program where required/appropriate; all required comments and documentation are present

8-9 Very Good – Pet class is well defined: class implements all requirements; exhibits very minor deficiencies (e.g. comments or naming)

6-7 Acceptable – Pet class is adequately defined: class implements most (less than 75%) requirements; exhibits minor deficiencies (e.g. comments, naming, or visibility)

4-5 Needs Work – Pet class is poorly defined: class implements less than half of the requirements; exhibits minor deficiencies (e.g. comments, naming, or visibility)

1-3 Unsatisfactory – Pet class is improperly defined: class implements less than half of the requirements; exhibits major deficiencies (e.g. comments, naming, visibility, types or signatures)

0 Not done; poorly implemented; class does not demonstrate any of the requirements Marking Rubric [Program Completion]

Mark Description 5 Excellent – program passes all test cases (see included sample run); coding follows best

practices and class standards; logic structure is efficient with no redundant code; program does not crash; program properly makes use of the user-defined class/objects

4 Very Good – program produces the expected results for most of the test case results; coding does not follow best practices and class standards in few instances; minor logic errors; redundant code; program does not crash; program properly makes use of the user- defined class/objects

3 Acceptable – program produces the expected results for some of the test case results; coding does not follow best practices and class standards in many instances; major logic errors; redundant code; program may crash unexpectedly; program makes use of the user- defined class/objects

2 Needs Work – program fails to produce expected results; coding does not follow best practices and class standards; major logic errors; redundant code; program crashes unexpectedly; program does not make use of the user-defined class/objects

1 Unsatisfactory – program fails to produce expected results; coding does not follow best practices and class standards; major logic errors; redundant code; aborts when executed/ program crashes always; program does not make use of the user-defined class/objects

0 Not done; poorly attempted; major logic errors; major design problems; a scaffold was submitted

CPSC1012 Assignment 4 – Fall 2021 Term

Marking Rubric [Part B – List and File Access Program Completion] Mark Description 5 Excellent – program correctly reads and writes Pet objects from files as required by the

program specifications; the program manages Pet objects in a List; errors when reading/writing files will not crash the program; required CSV file format is implemented for written files; defensive programming techniques are applied when appropriate

4 Very Good – program correctly reads and writes Pet objects from files as required by the program specifications; the program manages Pet objects in a List; errors when reading/writing files will not crash the program; required CSV file format is implemented for written files with minor error(s); defensive programming techniques are applied in some cases

3 Very Good – program correctly reads and writes Pet objects from files as required by the program specifications; the program manages Pet objects in a List; errors when reading/writing files will not crash the program; required CSV file format is implemented for written files with minor error(s); defensive programming techniques are applied in some cases

2 Needs Work – program reads or writes Pet objects from files with errors; the program does not use a List to manage Pet objects; errors when reading/writing files will crash the program; required CSV file format is not correctly implemented; defensive programming techniques are not applied

1 Unsatisfactory – program attempts much of the Part B requirements, but does not successfully implement any of them.

0 Not done; poorly attempted; files are neither written or read by the program; Pet objects are not managed by the program