Write a try catch block of code which invokes the treatpet


Is there someone to help me on to write c++ code?

A) Write a snippet of code to declare ( what would go into the .h file) and then implement(what go into the .cpp file) an exception class called PetBitesException which holds an error message ,and a method called erroHandler which prints a message to a log file errorlog . The message is set by the custom constructor. Assume the log file has been already opened, and is globally available.

B) Write a snippet of code to declare (what would go into .h file) and then implement (what go into .cpp file) a public void method called treatPets scoped to PetHospital class, which takes a reference to Pet object , and throws PetBitesException if a Pet's mood attribute is set to "annoyed" . The exception needs to ouput a message identifying the Pet(example "Rufus just bit"), where pet's name class and the Pet class with all its attributes have been already implemented.

C) Write a try catch block of code, which invokes the treatPet method, catches PetBitesException and then invokes the errorHandler method on the exception object to log the error message.

D) Objective: class hierarchy and polymorphishm. Write a code snippet of code to declare (what would go into .h file) and then implement (what would go into .cpp file) the family of classes in Quality Control domain including,

- the base class "Test"

- two derived classes corresponding to the specialize tests: RegressionTest and LoadTest

The base class should have a virtual Boolean method called run which is overridden in the sub-classes, where specified logic is placed(some code).

As an exercise, let the method return true false randomly. Then in main.cpp file, declare a pointer to the base class Test and use it to instantiate and run LoadTest. Then use the same pointer to instantiate and run a RegressionTest.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a try catch block of code which invokes the treatpet
Reference No:- TGS02928148

Expected delivery within 24 Hours