CPSC 1012 Assignment: Object-Oriented Programming
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 clinics 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.
Recent Comments