0% found this document useful (0 votes)
28 views5 pages

POO Lab 5

This document contains code for modeling a library system using object-oriented programming principles in C++. It defines classes such as Library, Item, Book, and Magazine to represent different types of library content. Methods like display(), read(), and buy() are implemented to interact with instances of these classes. The code samples an item being checked out to demonstrate the object interactions.

Uploaded by

Greed MD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views5 pages

POO Lab 5

This document contains code for modeling a library system using object-oriented programming principles in C++. It defines classes such as Library, Item, Book, and Magazine to represent different types of library content. Methods like display(), read(), and buy() are implemented to interact with instances of these classes. The code samples an item being checked out to demonstrate the object interactions.

Uploaded by

Greed MD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Universitatea Tehnică a Moldovei

Facultatea Calculatoare Informatică și Microelectronică


Specialitatea Tehnologii Informaționale

RAPORT
la lucrarea de laborator nr. 5

la Programarea Orientată pe Obiecte

A efectuat: Grosu Cristian TI-201


A verificat: Scrob Sergiu

Chişinău 2021
#include <iostream>

#include <string>

#include <string.h>

#include <stdlib.h>

using namespace std;

class Library{

public:

virtual void afisare(){}

virtual void read(){}

virtual void buy(){}

};

class Continut{

public:

string content;

Continut() {}

Continut(string content) {

this->content = content;

void operator=(Continut a1) {

content = a1.content;

friend ostream& operator<<(ostream& os, const Continut& dt) {

cout << dt.content;

return os;

};

class Pagina:public Continut{

public:
int nr;

Continut a1;

Pagina() {}

Pagina(int nr,Continut content) {

this->nr = nr;

this->a1 = content;

virtual void afisare() {

cout << "\nNr.paginei:" << nr;

cout << "\nContinut:" << a1;

};

class Item:public Pagina{

protected:

string name;

string author;

Pagina page;

Item() {};

virtual void afisare() {

};

class Carte:protected Item,public Library{

public:

Carte() {}

Carte(string name,string author) {

this-> name = name;


this-> author = author;

Carte(string name,string author,Pagina page) {

this-> name = name;

this-> author = author;

this->page = page;

virtual void afisare(Carte a1) {

cout << "\nLibrarie" ;

cout << "\nNumele:" << a1.name;

cout << "\nAutor:" << a1.author;

cout << "\nNr.pag:" << page.nr;

cout << "\nContent:" << page.a1;

};

class Revista:protected Item,public Library{

public:

Revista() {}

Revista(string name,string author) {

this-> name = name;

this-> author = author;

Revista(string name,string author,Pagina page) {

this-> name = name;

this-> author = author;

this->page = page;

}
virtual void afisare(Revista a1) {

cout << "\nNumele:" << a1.name;

cout << "\nAutor:" << a1.author;

cout << "\nNr.pag:" << page.nr;

cout << "\nContent:" << page.a1;

};

int main() {

Continut pf("Piatra Filozofica");

Pagina first(1,pf);

//first.afisare();

Carte book("Harry Potter","J.K.Rowling",first);

book.afisare(book);

cout << "\n";

Revista rev1("Harry Potter","J.K.Rowling",first);

rev1.afisare(rev1);

rev1.buy();

You might also like