1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
//
// main.cpp
// RESISTOR_CLASS
#include <iostream>
using namespace std;
class resistor
{
private:
string Band_1_Color;
string Band_2_Color;
string Band_3_Color;
string Band_4_Color;
int First_Digit;
int Second_Digit;
int Multiplier;
int Tolerance;
int value;
int Blue;
int Black;
int Brown;
int Red;
int Orange;
int Yellow;
int Green;
int Purple;
int Gray;
int White;
float Gold;
float Silver;
public:
void print_value();
void setBand_1_Color(string Band_1);
void setBand_2_Color(string Band_2);
void setBand_3_Color(string Band_3);
void setBand_4_Color(string Band_4);
int getFirst_Digit();
int getSecond_Digit();
int getMultiplier();
int getTolerance();
resistor(string Band_1 = " ", string Band_2 = " ", string Band_3 = " ", string Band_4 = " ");
resistor(int Digit_1 = 0, int Digit_2 = 0, int M = 0, int T = 0);
resistor(int blue = 6,int black = 0,int brown = 1,int red = 2,int orange = 3,
int yellow = 4,int green = 5,int purple = 7,int gray = 8,int white = 9,
float gold = 0.1,float silver = 0.01);
};
int main()
{
resistor myresistor;
myresistor.setBand_1_Color;
myresistor.setBand_2_Color;
myresistor.setBand_3_Color;
myresistor.setBand_4_Color;
return 0;
}
void resistor::print_value()
{
cout << Band_1_Color << " " << Band_2_Color << " "
<< Band_3_Color << " " << Band_4_Color << endl;
cout << "Value = " << "\n";
}
void resistor::setBand_1_Color(string Band_1)
{
cout << "Enter Color of Band 1: ";
cin >> Band_1;
Band_1_Color = Band_1;
}
void resistor::setBand_2_Color(string Band_2)
{
cout << "Enter Color of Band 2: ";
cin >> Band_2;
Band_2_Color = Band_2;
}
void resistor::setBand_3_Color(string Band_3)
{
cout << "Enter Color of Band 3: ";
cin >> Band_3;
Band_3_Color = Band_3;
}
void resistor::setBand_4_Color(string Band_4)
{
cout << "Enter Color of Band 2: ";
cin >> Band_4;
Band_4_Color = Band_4;
}
int resistor::getFirst_Digit()
{
return First_Digit;
}
int resistor::getSecond_Digit()
{
return Second_Digit;
}
int resistor::getMultiplier()
{
return Multiplier;
}
int resistor::getTolerance()
{
return Tolerance;
}
resistor::resistor(string Band_1, string Band_2, string Band_3, string Band_4)
{
Band_1_Color = Band_1;
Band_2_Color = Band_2;
Band_3_Color = Band_3;
Band_4_Color = Band_4;
}
resistor::resistor(int Digit_1, int Digit_2, int M, int T)
{
First_Digit = Digit_1;
Second_Digit = Digit_2;
Multiplier = M;
Tolerance = T;
}
resistor::resistor(int blue,int black,int brown,int red,int orange,
int yellow,int green,int purple,int gray,int white,
float gold,float silver)
{
Blue = blue;
Black = black;
Brown = brown;
Red = red;
Orange = orange;
Yellow = yellow;
Green = green;
Purple = purple;
Gray = gray;
White = white;
Gold = gold;
Silver = silver;
}
|