mirror of https://github.com/Askill/AP-SCE.git
actually used the cpps
This commit is contained in:
parent
41b85a5124
commit
5db523bfdf
|
|
@ -12,8 +12,5 @@ class Circle : public Shape
|
|||
public:
|
||||
Circle() {}
|
||||
~Circle() {}
|
||||
long double compute_area(long double d) override
|
||||
{
|
||||
return (d / 2)*(d / 2) * 3.14159265359;
|
||||
}
|
||||
long double compute_area(long double) override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,2 +1,89 @@
|
|||
#include "3d.h"
|
||||
#include "2d.h"
|
||||
using namespace std;
|
||||
|
||||
void Cylinder::data_entry()
|
||||
{
|
||||
char auswahl = 'j';
|
||||
long double teil_lange;
|
||||
long double teil_durchmesser;
|
||||
long double teil_dichte;
|
||||
long double teil_widerstand;
|
||||
|
||||
//Data entry
|
||||
while (auswahl == 'j')
|
||||
{
|
||||
//Reseting the variables
|
||||
teil_lange = 0;
|
||||
teil_durchmesser = 0;
|
||||
teil_dichte = 0;
|
||||
teil_widerstand = 0;
|
||||
|
||||
|
||||
cout << "Definieren Sie die Teilabschnitte des Zylinders" << endl;
|
||||
cout << " Laenge in mm: "; cin >> teil_lange; heights.push_back(teil_lange);
|
||||
cout << " Durchmesser in mm: "; cin >> teil_durchmesser; radii.push_back(teil_durchmesser);
|
||||
cout << " Dichte in g/mm^3: "; cin >> teil_dichte; densities.push_back(teil_dichte);
|
||||
cout << " Spezifischer Widerstand in ohm * (mm^2) / m: "; cin >> teil_widerstand; resistances.push_back(teil_widerstand);
|
||||
cout << " Gibt es weitere Teilbereiche? j/n "; cin >> auswahl;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
|
||||
void Cylinder::compute_options() {
|
||||
//Compute
|
||||
char auswahl = 'j';
|
||||
while (auswahl == 'j')
|
||||
{
|
||||
cout << "Was wollen Sie berechnen?" << endl;
|
||||
cout << " 1 Volumen" << endl;
|
||||
cout << " 2 Masse" << endl;
|
||||
cout << " 3 Elektrischer Widerstand" << endl;
|
||||
|
||||
cin >> auswahl;
|
||||
switch (auswahl)
|
||||
{
|
||||
case '1': cout << "Volumen: " << compute_volume() << " mm^3" << endl; break;
|
||||
case '2': cout << "Masse: " << compute_mass() << " g" << endl; break;
|
||||
case '3': cout << "Widerstand: " << compute_electric_resistamce() << " ohm" << endl; break;
|
||||
|
||||
default: cout << "Okay, bye" << endl; break;
|
||||
}
|
||||
cout << "Wollen Sie fortfahren? j/n "; cin >> auswahl;
|
||||
}
|
||||
}
|
||||
|
||||
long double Cylinder::compute_volume()
|
||||
{
|
||||
long double Volume = 0;
|
||||
Circle circle;
|
||||
for (int i = 0; heights.size() != i; i++)
|
||||
{
|
||||
Volume = Volume + heights[i] * circle.compute_area(radii[i]);
|
||||
}
|
||||
set_volume(Volume);
|
||||
return Volume;
|
||||
}
|
||||
long double Cylinder::compute_mass()
|
||||
{
|
||||
long double mass = 0;
|
||||
Circle circle;
|
||||
for (int i = 0; heights.size() != i; i++)
|
||||
{
|
||||
mass = mass + heights[i] / 10 * circle.compute_area(radii[i] / 10) * densities[i];
|
||||
}
|
||||
set_mass(mass);
|
||||
return mass;
|
||||
}
|
||||
long double Cylinder::compute_electric_resistamce()
|
||||
{
|
||||
long double resistance = 0;
|
||||
Circle circle;
|
||||
for (int i = 0; heights.size() != i; i++)
|
||||
{
|
||||
resistance = resistance + ((heights[i] / 1000) * resistances[i]) / circle.compute_area(radii[i]);
|
||||
}
|
||||
set_electric_resistance(resistance);
|
||||
return resistance;
|
||||
}
|
||||
|
|
|
|||
91
SCE/SCE/3d.h
91
SCE/SCE/3d.h
|
|
@ -1,6 +1,6 @@
|
|||
#include <vector>
|
||||
#include <iostream>
|
||||
#include "2d.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Body
|
||||
|
|
@ -42,88 +42,9 @@ public:
|
|||
Cylinder() {};
|
||||
~Cylinder(){};
|
||||
|
||||
void data_entry() override
|
||||
{
|
||||
char auswahl = 'j';
|
||||
long double teil_lange;
|
||||
long double teil_durchmesser;
|
||||
long double teil_dichte;
|
||||
long double teil_widerstand;
|
||||
|
||||
//Data entry
|
||||
while (auswahl == 'j')
|
||||
{
|
||||
//Reseting the variables
|
||||
teil_lange = 0;
|
||||
teil_durchmesser = 0;
|
||||
teil_dichte = 0;
|
||||
teil_widerstand = 0;
|
||||
|
||||
|
||||
cout << "Definieren Sie die Teilabschnitte des Zylinders" << endl;
|
||||
cout << " Laenge in mm: "; cin >> teil_lange; heights.push_back(teil_lange);
|
||||
cout << " Durchmesser in mm: "; cin >> teil_durchmesser; radii.push_back(teil_durchmesser);
|
||||
cout << " Dichte in g/mm^3: "; cin >> teil_dichte; densities.push_back(teil_dichte);
|
||||
cout << " Spezifischer Widerstand in ohm * (mm^2) / m: "; cin >> teil_widerstand; resistances.push_back(teil_widerstand);
|
||||
cout << " Gibt es weitere Teilbereiche? j/n "; cin >> auswahl;
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
void compute_options() override
|
||||
{
|
||||
//Compute
|
||||
char auswahl = 'j';
|
||||
while (auswahl == 'j')
|
||||
{
|
||||
cout << "Was wollen Sie berechnen?" << endl;
|
||||
cout << " 1 Volumen" << endl;
|
||||
cout << " 2 Masse" << endl;
|
||||
cout << " 3 Elektrischer Widerstand" << endl;
|
||||
|
||||
cin >> auswahl;
|
||||
switch (auswahl)
|
||||
{
|
||||
case '1': cout << "Volumen: " << compute_volume() << " mm^3" << endl; break;
|
||||
case '2': cout << "Masse: " << compute_mass() << " g" << endl; break;
|
||||
case '3': cout << "Widerstand: " << compute_electric_resistamce() << " ohm" << endl; break;
|
||||
|
||||
default: cout << "Okay, bye" << endl; break;
|
||||
}
|
||||
cout << "Wollen Sie fortfahren? j/n "; cin >> auswahl;
|
||||
}
|
||||
}
|
||||
long double compute_volume() override
|
||||
{
|
||||
long double Volume = 0;
|
||||
Circle circle;
|
||||
for (int i = 0; heights.size() != i; i++)
|
||||
{
|
||||
Volume = Volume + heights[i] * circle.compute_area(radii[i]);
|
||||
}
|
||||
set_volume(Volume);
|
||||
return Volume;
|
||||
}
|
||||
long double compute_mass()override
|
||||
{
|
||||
long double mass = 0;
|
||||
Circle circle;
|
||||
for (int i = 0; heights.size() != i; i++)
|
||||
{
|
||||
mass = mass + heights[i]/10 * circle.compute_area(radii[i]/10) * densities[i];
|
||||
}
|
||||
set_mass(mass);
|
||||
return mass;
|
||||
}
|
||||
long double compute_electric_resistamce() override
|
||||
{
|
||||
long double resistance = 0;
|
||||
Circle circle;
|
||||
for (int i = 0; heights.size() != i; i++)
|
||||
{
|
||||
resistance = resistance + ((heights[i]/1000) * resistances[i]) / circle.compute_area(radii[i]);
|
||||
}
|
||||
set_electric_resistance(resistance);
|
||||
return resistance;
|
||||
}
|
||||
void data_entry() override;
|
||||
void compute_options() override;
|
||||
long double compute_volume() override;
|
||||
long double compute_mass()override;
|
||||
long double compute_electric_resistamce() override;
|
||||
};
|
||||
Loading…
Reference in New Issue