自己写的选课系统,命令行下的...比较简陋...

源代码在线查看: time.cpp

软件大小: 39 K
上传用户: lihuitao1987
关键词: 命令行 比较
下载地址: 免注册下载 普通下载 VIP

相关代码

				#include 
				#include "Time.h"
				
				Time::Time(String str)
				{
					int i,j;
					char *buffer = new char[str.getlenth() + 1];
					for (i = 0; i < str.getlenth() + 1; i++)
						buffer[i] = str.getChar(i);
					j = 4;
					while (i >= 0)
					{
						if (buffer[i] == '.')
						{
							time[j] = atoi(buffer + i + 1);
							j--;
							buffer[i] = '\0';
						}
						i--;
					}
					time[j--] = atoi(buffer);
					while (j >= 0)
					{
						time[j] = 0;
						j--;
					}
					delete [] buffer;
				}
				
				Time::~Time()
				{
				}
				
				int Time::GetTime(int i)
				{
					if (i >= 0 && i < 5)
						return time[i];
					else
						return -1;
				}
				
				bool Time::operator==(const Time& t) const
				{
					int i = 0;
					bool flag = true;
					while (i < 5 && time[i] == t.time[i])
					{
							i++;
					}
					if (i < 5)
						flag = false;
					return flag;
				}			

相关资源