Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <vector>
- #include <cmath>
- #include <cctype>
- #include <array>
- using namespace std;
- class Part{
- string Name;
- int Sn;
- double Weight;
- string Type;
- public:
- string setType(double weight) {
- return (weight > 50) ? "heavy" : "light";
- }
- private:
- void init(string name, int Sn, int Weight){
- Name = name;
- this->Sn = Sn;
- this->Weight = Weight;
- Type = setType(Weight);
- }
- public:
- Part(){
- init("unknown part", 0, 0);
- }
- Part(string Name){
- init(Name, 0, 0);
- }
- Part(string name, int Sn, int Weight){
- init(Name, Sn, Weight);
- }
- void setParam(int sn, int weight){
- init(Name, sn, weight);
- }
- /* //////////////////////////////////////// kaip padaryti, kad pagal varda grazintu Sn?
- double getSn(string name){
- ...
- return Sn;
- }
- */ ///////////////////////////////////////
- void getPartInf(){
- cout << Name << "|" << Sn << "|" << Weight << "|" << Type << endl;
- }
- };
- int main(){
- Part p1(), p2("stumoklis"), p3("piston", 2546, 32);
- p3.getPartInf();
- p2.setParam(3567, 55);
- p2.getPartInf();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement