1613-3-傅溥衍 总结《2016年11月11日》【连续四十二天总结】

  标题:类和对象
关键词:汽车类的设计
内容: 
A今日完成情况

1.看类70%


B具体内容

做了下小汽车的程序,编译还有错误。


C明日计划

A把小汽车弄好

B园类设计



汽车类函数

#include<iostream>
#include<windows.h>
#include<mmsystem.h>   //媒体控制函数
#pragma comment(lib,"winmm.lib")
using namespace std;
class automoble
{
	private:
		char type[20];
		char color[20];
		float price;
		int carry_weight;
		int carry_customer;
public:
	void set_data(char *t,char *c,float pri,int cw,int cc);
	void movecar(int l,int k);
	void horming(int num);
	void downcar(int l);
	void play_mp3(char *ps);
	char *show_type()
	{
	return type;
	}
};  
void automobile::set_data(char *t,char *c,float pri,int cw,int cc)
{
	strcpy(type,t);
	strcpy(color,c);
	price=pri;
	carry_weight=cw;
	carry_custom=cc;
}
void automobile::movecar(int l,int k)
{
	cout<<"\n"<<type<<"水平直线运动:"<<endl;
	for(int i=0;i<l;i++)
	{
		cout<<' '<<"o_o";    //o_o这个是汽车轮
		Sleep(1000/k);
		cout<<"\b\b\b";    //转义字符 回格 
	}
}
void automobile::downcar(int l)
{
	//垂直向下运动
	cout<<"\n"<<type<<"垂直向下运动:"<<endl;
	for(int i=0;i<l;i++)
	{
		cout<<"o_o";
		Sleep(500);
		cout<<"\b\b\b"<<"  "<<endl;
	 } 
 } 
void automobile::horming(int num)
 {
 	for(int i=0;i<num;i++)
 	{
 		cout<<type;
 		cout<<"\007"<<"  di di di  "<<endl;
		 Sleep(1000); 
	 }
 }
void automobile::play_mp3(char *ps)
 {
 	char str[100]="play";
 	strcat(str,ps);
 	cout<<str;
 	mciSendStringA(str,NULL,0,NULL);
 	char a;
 	cin>>a;
 }
 int main()
 {
 	automobile nison;
 	char tp[]="yyida";
 	char ys[]="white";
 	nison.set_data(tp,ys,200000,5,3);
 	nison.horming(5);
 	nison.movecar(10,3);
 	nison.downcar(8);
 	char mp[]="d:\\薛之谦_绅士.mp3";
 	nison.play_mp3(mp);
 	return 0;
 }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值