Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that uses the class bookType and tests various operations on the

ID: 3527389 • Letter: W

Question

Write a program that uses the class bookType and tests various operations on the objects of the class bookType. Declare an array of 100 components of type bookType. Some of the operations that you should perform are to search for a book by its title, search by ISBN, and update the number of copies of a book.

Explanation / Answer

PLEASE RATE ME AND AWARD ME KARMA POINTS IF IT IS HELPFUL FOR YOU A class is defined by: class MyClass { /* public, protected and private variables, constants, and functions */ }; An object of type MyClass (case-sensitive) is declared using: MyClass object; by default, all class members are initially private. keywords public and protected allow access to class members. classes contain not only data members, but also functions to manipulate that data. a class is used as the basic building block of OOP (this is a distinction of convention, not of language-enforced semantics). A class can be created before main() is called. when a function is called in which the object is declared. when the "new" operator is used. Class Names Name the class after what it is. If you can't determine a name, then you have not designed the system well enough. Compound names of over three words are a clue your design may be confusing various entities in your system. Revisit your design. Try a CRC card session to see if your objects have more responsibilities than they should. Avoid the temptation of naming a class something similar to the class it is derived from. A class should stand on its own. Declaring an object with a class type doesn't depend on where that class is derived from. Suffixes or prefixes are sometimes helpful. For example, if your system uses agents then naming something DownloadAgent conveys real information. Data Abstraction A fundamental concept of Object Oriented (OO) recommends an object should not expose any of its implementation details. This way, you can change the implementation without changing the code that uses the object. The class, by design, allows its programmer to hide (and also prevents changes as to) how the class is implemented. This powerful tool allows the programmer to build in a 'preventive' measure. Variables within the class often have a very significant role in what the class does, therefore variables can be secured within the private section of the class. [edit]Access labels The access labels Public, Protected and Private are used within classes to set access permissions for the members in that section of the class. All class members are initially private by default. The labels can be in any order. These labels can be used multiple times in a class declaration for cases where it is logical to have multiple groups of these types. An access label will remain active until another access label is used to change the permissions. We have already mentioned that a class can have member functions "inside" it; we will see more about them later. Those member functions can access and modify all the data and member function that are inside the class. Therefore, permission labels are to restrict access to member function that reside outside the class and for other classes. For example, a class "Bottle" could have a private variable fill, indicating a liquid level 0-3 dl. fill cannot be modified directly (compiler error), but instead Bottle provides the member function sip() to reduce the liquid level by 1. Mywaterbottle could be an instance of that class, an object. /* Bottle - Class and Object Example */ #include #include using namespace std; class Bottle { private: // variables are modified by member functions of class int iFill; // dl of liquid public: Bottle() // Default Constructor : iFill(3) // They start with 3 dl of liquid { // More constructor code would go here if needed. } bool sip() // return true if liquid was available { if (iFill > 0) { --iFill; return true; } else { return false; } } int level() const // return level of liquid dl { return iFill; } }; // Class declaration has a trailing semicolon int main() { // terosbottle object is an instance of class Bottle Bottle terosbottle; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote