PLEASE NOTE : FEEL FREE TO ASK ANY DOUBTS by COMMENTING
Language : C++ Programming
IDE : Dev C++
:::::::::::::::::::::::::::::::::::::::::::: CODE ::::::::::::::::::::::::::::::::::::::::
#include <iostream>
#include <cstring>
using namespace std;
// book class
class book{
// public variables
public:
// constructor
book(char*,char *,int);
// to show book details
void show_book();
// private variables
private:
// title, author, pages
char title[64];
char author[64];
int pages;
};
// implementing class functions
book::book(char *title,char *author, int pages){
// copying title, author. Assigning pages
strcpy(this->title,title);
strcpy(this->author,author);
this->pages = pages;
}
void book::show_book(){
// showing book details
cout << "Title: " << title <<
endl;
cout << "Author: " << author <<
endl;
cout << "Pages: " << pages <<
endl;
}
// class LibraryCard that inherits book class
class LibraryCard:book{
// private variables
private:
// chatalog and checked_out
value
char catalog[64];
int checked_out;
// public variables
public:
// constructor
LibraryCard(char *,char
*,int,char*,int);
// to show catalog details
void show_card();
};
// constructor that calls base class constructor
LibraryCard::LibraryCard(char *title,char *author,int pages,
char *catalog,int
checked_out):book(title,author,pages){
// copy catalog and assign checkedout value
strcpy(this->catalog,catalog);
this->checked_out = checked_out;
}
void LibraryCard::show_card(){
// call base class method show_book
book::show_book();
// print catalog
cout << "Catalog: " << catalog <<
endl;
// if checked_out value is 1, printing "Checked
out"
cout << "Status: ";
if(checked_out==1){
cout << "Checked out";
}
// if checked_out value is not 1, printing
"Avaiable"
else{
cout << "Available";
}
cout << endl;
}
int main(){
// required variables with values
char title[] = "C++ How to Program";
char author[] = "Deitel & Deitel";
int pages = 1400;
char catalog[] = "300CPP";
int checked_out = 1;
// creating LibraryCard instance
LibraryCard
l(title,author,pages,catalog,checked_out);
// calling show_card of above instance
cout << "*************************\n";
l.show_card();
cout << "*************************\n";
return 0;
}
:::::::::::::::::::::::::::::::::::::::::::: OUTPUT ::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::: CODE in EDITOR ::::::::::::::::::::::::::::::::::


_________________________________________________________________
Dear Friend, Feel Free to Ask Any Doubts by Commenting. ASAP i'll respond when i'm available.
I'm on a critical Situation. Please Do Not Forget To Give A Thumbs UP +1. It will Helps me A Lot.
Thank YOU :-)
Please use C++ Suppose we have the following book base class: class book { public: book(char*,...
Suppose we have the following book base class: class book { public: book(char *, char *, int); void show_book(); private: char title[64]; char author[64]; int pages; }; Suppose that we need to derive a new class, called libraryCard class, which adds the following members to the book class: char catalog[64]; int checked out; // 1 if checked out, otherwise 0 if available libraryCard(char *, char *, int, char *, int); void show_card(); 1. Derive the new class from the base...
C++ program
Suppose we have the following book base class: class book { public: book(char *, char *, int); void show_book(); private: char title[64]; char author[64]; int pages; }; Suppose that we need to derive a new class, called libraryCard class, which adds the following members to the book class: char catalog[64]; int checked out; // 1 if checked out, otherwise 0 if available libraryCard(char *, char *, int, char *, int); void show_card(); 1. Derive the new class from...
Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use implements Comparable<Book> in the class definition. Now, all book objects are instances of the java.lang.Comparable interface. Write a test program that creates an array of ten books. 1. Use Arrays.sort( Book[]l books) from the java.util package to sort the array. The order of objects in the array is determined using compareTo...) method. 2. Write a method that returns the most expensive book in the...
You are going to model a Book in a library. The Book class should contain a title and an author (exactly 1 author is OK). Also, a book can be checked out and returned by a student. A Book object should be able to identify the student who currently holds the book. 1.Design the public interface (public constructor and public methods) for a class Book. You can use String to represent title, author, and student. 2. Implement the class Book...
please Code in c++ Create a new Library class. You will need both a header file and a source file for this class. The class will contain two data members: an array of Book objects the current number of books in the array Since the book array is moving from the main.cc file, you will also move the constant array size definition (MAX_ARR_SIZE) into the Library header file. Write the following functions for the Library class: a constructor that initializes...
C++
In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a "next" pointer. Textbook Туре String String String Attribute title author ISBN Textbook* next Library class should have a head node as an attribute to keep the list of the books. Also, following member...
Create a base class named Book. Data fields include title and author; functions include those that can set and display the fields. Derive two classes from the Book class: Fiction, which also contains a numeric grade reading level, and NonFiction, which contains a variable to hold the number of pages. The functions that set and display data field values for the subclasses should call the appropriate parent class functions to set and display the common fields, and include specific code...
1- Create the base class Book that has the following instance variables, constructor, and methods title ( String) isbn ( String) authors (String) publisher (String) edition ( int) published_year (int) Constructor that takes all of the above variables as input parameters. set/get methods ToString method // that return sting representation of Book object. 2- Create the sub class New_Book that is derived from the base class Book and has the following instance variables, constructor, and methods: title ( String) isbn...
JAVA Objective : • Learning how to write a simple class. • Learning how to use a prewritten class. • Understanding how object oriented design can aid program design by making it easier to incorporate independently designed pieces of code together into a single application. Instructions: • Create a project called Lab13 that contains three Java file called Book.java , Bookstore.java and TempleBookstore.java • I’ve provided a screenshot of how your project should look like. • Be sure to document...
Create a class called Restaurant that is the base class for all restaurants. It should have attributes for the restaurant's name{protected) and seats (private attribute that represents the number of seats inside the restaurant). Use the UML below to create the methods. Note, the toString prints the name and the number of seats. Derive a class Fastfood from Restaurant This class has one attribute - String slogan (the slogan that the restaurants uses when advertising - e.g., "Best Burgers Ever!")....