📄 cpp1.cpp
字号:
#include<iostream.h>
#include<stdlib.h>
#include<fstream.h>
class carstore
{
public:
carstore(int n){sqcar=n;};
//~carstore();
int sqcar;
};
class trustore
{
public:
trustore(int n){sqtru=n;};
//~trustore();
int sqtru;
};
class trastore
{
public:
trastore(int n){sqtra=n;};
//~trastore();
int sqtra;
};
class vehicle
{
public:
int price;
int amount;
};
class car:public vehicle
{
public:
car(int a){price=50000;amount=a;}
~car();
};
class truck:public vehicle
{
public:
truck(int a){price=80000;amount=a;}
~truck();
};
class tractor:public vehicle
{
public:
tractor(int a){price=7000;amount=a;}
~tractor();
};
void store()
{
int k;
while(1)
{
cout<<"请选择你想要的操作"<<endl;
cout<<"1.储存货物"<<endl;
//cout<<"2.Move out the product"<<endl;
cout<<"0.退出"<<endl;
cin>>k;
switch(k)
{
case 1:
{
int number,kind;
cout<<"请输入你要储存的产品的种类:"<<endl;
cout<<"1.汽车"<<'\n';
cout<<"2.卡车"<<'\n';
cout<<"3.农用车"<<'\n'<<endl;
cin>>kind;
cout<<"请输入生产部门要储存的产品数量:"<<endl;
cin>>number;
switch(kind)
{
case 1:
{
carstore CARSTORE(number);
ofstream outstuf;
outstuf.open("D:\\companyfile\\物流文件.txt",ios::out);
outstuf<<"汽车库存量:"<<CARSTORE.sqcar<<endl;
outstuf.close();
continue;
}
case 2:
{
trustore TRUSTORE(number);
ofstream outstuf;
outstuf.open("D:\\companyfile\\物流文件.txt",ios::out);
outstuf<<"卡车库存量:"<<TRUSTORE.sqtru<<endl;
outstuf.close();
return;
}
case 3:
{
trastore TRASTORE(number);
ofstream outstuf;
outstuf.open("D:\\companyfile\\物流文件.txt",ios::out);
outstuf<<"农用车库存量:"<<TRASTORE.sqtra<<endl;
outstuf.close();
return;
}
}
}
case 2:
{
return;
}
default:
{
cout<<"输入错误,请重新选择"<<'\n'<<endl;
}
}
};
}
void main()
{
store();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -