Skip to content

Instantly share code, notes, and snippets.

@BraynStorm
Created December 16, 2014 10:48
Show Gist options
  • Save BraynStorm/5afff8692901d2d413e2 to your computer and use it in GitHub Desktop.
Save BraynStorm/5afff8692901d2d413e2 to your computer and use it in GitHub Desktop.
Zadacha1_Razdel2Test
#include <iostream>
#include <cstdlib>
using namespace std;
class LinearEquasion{
private:
double a,b;
public:
LinearEquasion(){
cout << "Vuvedi a,b: ";
cin >> a >> b;
}
bool isDataValid(){
return a != 0 || (a == 0 && b == 0);
}
void printSolution(){
if(isDataValid()){
if(a==0){
cout << "Vsqko X e reshenie." << endl;
return;
}
cout << "Reshenieto e: " << b/a << endl;
return;
}
cout << "Nqma reshenie." << endl;
}
~LinearEquasion(){
cout << "Destoying object..." << endl;
}
};
int main(){
LinearEquasion *a = new LinearEquasion();
if(a->isDataValid()){
cout << "Informaciqta e validna" << endl;
a->printSolution();
}else{
cout << "Informaciqta e nevalidna" << endl;
}
delete (a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment