Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////////Numeral.h/////////////////////////////////////////////////////////
- #pragma once
- class Numeral
- {
- int Numeral;
- public:
- Numeral(int );
- int const getNumeral() const;
- void Swap(int);
- void const Print() const;
- ~Numeral();
- };
- //////////////////////////Numeral.cpp///////////////////////////////////////////////////////
- #include "Numeral.h"
- #include <iostream>
- Numeral::Numeral(int c)
- {
- if (c < 0)
- Numeral = 0;
- else if (c > 9)
- Numeral = 9;
- else
- Numeral = c;
- }
- int const Numeral::getNumeral() const
- {
- return Numeral;
- }
- void Numeral::Swap(int c)
- {
- if (c < 0)
- Numeral = 0;
- else if (c > 9)
- Numeral = 9;
- else
- Numeral = c;
- }
- void const Numeral::Print() const
- {
- std::cout << Numeral << " ";
- }
- Numeral::~Numeral()
- {
- }
- ////////////////////////NumeralLCD.h////////////////////////////////////////////////////////////////////
- #pragma once
- #include "Numeral.h"
- class NumeralLCD :public Numeral
- {
- public:
- NumeralLCD();
- NumeralLCD(int Numeral);
- void Print() const;
- ~NumeralLCD();
- };
- //////////////////////////NumeralLCD.cpp////////////////////////////////////////////////////
- #include "NumeralLCD.h"
- #include <iostream>
- using namespace std;
- NumeralLCD::NumeralLCD() : Numeral(0)
- {
- }
- NumeralLCD::NumeralLCD(int Numeral) : Numeral(Numeral)
- {
- }
- void NumeralLCD::Print() const
- {
- switch(getNumeral())
- {
- case 0: std::cout << endl
- << " ## " << std::endl
- << " # # " << endl
- << " # # " << endl
- << " # # " << endl
- << " ## ";
- break;
- case 1: std::cout << endl
- << " ## " << std::endl
- << " # # " << endl
- << " # # " << endl
- << " # " << endl
- << " # ";
- break;
- case 2: std::cout << endl
- << " ## " << std::endl
- << " # # " << endl
- << " # " << endl
- << " # " << endl
- << " #### ";
- break;
- case 3: std::cout << endl
- << " ## " << std::endl
- << " # # " << endl
- << " ### " << endl
- << " # # " << endl
- << " ## ";
- break;
- case 4: std::cout << endl
- << " # # " << std::endl
- << " # # " << endl
- << " #### " << endl
- << " # " << endl
- << " # ";
- break;
- case 5: std::cout << endl
- << " #### " << std::endl
- << " # " << endl
- << " ### " << endl
- << " # # " << endl
- << " ## ";
- break;
- case 6: std::cout << endl
- << " ## " << std::endl
- << " # " << endl
- << " ### " << endl
- << " # # " << endl
- << " ## ";
- break; 1
- case 7: std::cout << endl
- << " ##### " << std::endl
- << " # " << endl
- << " ### " << endl
- << " # " << endl
- << " # ";
- break;
- case 8: std::cout << endl
- << " ### " << std::endl
- << " # # " << endl
- << " ### " << endl
- << " # # " << endl
- << " ### ";
- break;
- case 9: std::cout << endl
- << " ## " << std::endl
- << " # # " << endl
- << " #### " << endl
- << " # " << endl
- << " ## ";
- break;
- }
- }
- NumeralLCD::~NumeralLCD()
- {
- }
- //////////////////////////NumeralRoman.h//////////////////////////////////////////////////
- #pragma once
- #include "Numeral.h"
- class NumeralRoman :public Numeral
- {
- public:
- NumeralRoman();
- NumeralRoman(int Numeral);
- void Print();
- ~NumeralRoman();
- };
- //////////////////////////NumeralRoman.cpp////////////////////////////////////////////////
- #include "NumeralRoman.h"
- #include <iostream>
- NumeralRoman::NumeralRoman() : Numeral(0)
- {
- }
- NumeralRoman::NumeralRoman(int Numeral) : Numeral(Numeral)
- {
- }
- void NumeralRoman::Print()
- {
- switch(getNumeral())
- {
- case 0: std::cout << " ";
- break;
- case 1: std::cout << "I ";
- break;
- case 2: std::cout << "II ";
- break;
- case 3: std::cout << "III";
- break;
- case 4: std::cout << "IV ";
- break;
- case 5: std::cout << "V ";
- break;
- case 6: std::cout << "VI ";
- break;
- case 7: std::cout << "VII ";
- break;
- case 8: std::cout << "VIII ";
- break;
- case 9: std::cout << "IX ";
- break;
- }
- }
- NumeralRoman::~NumeralRoman()
- {
- }
- ///////////////////////////Multiple_Inheritance.cpp///////////////////////////////////
- #include "stdafx.h"
- #include <conio.h>
- #include "Numeral.h"
- #include "NumeralRoman.h"
- #include "NumeralLCD.h"
- int main()
- {
- Numeral zero(0);
- Numeral eight(8);
- Numeral five(5);
- NumeralRoman one(1);
- NumeralRoman nine(35);
- NumeralLCD three(3);
- NumeralLCD zero1(-21);
- NumeralLCD seven(7);
- zero.Print();
- eight.Print();
- five.Print();
- one.Print();
- nine.Print();
- three.Print();
- zero1.Print();
- seven.Print();
- _getch();
- return 0;
- }
- 2
Advertisement
Add Comment
Please, Sign In to add comment