All pastes #56380 Raw Edit

Someone

public text v1 · immutable
#56380 ·published 2006-05-16 21:56 UTC
rendered paste body
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <iostream>
#include <cstdlib>

#include "Time.h" //Time class
#include "List.h"

int timecmp(const Time,const Time);
void ypepst(Time *);
void yps(list,Time *);
void ypsrc(Time *,Time *);
void sh(Time,list,Time);


int main(int argc, char *argv[])
{
	Time epst, rc;
	list snds;
	int tmp;
	bool stdf = 0;

	while (tmp != 5)
	{
		printf("1. Ypologismos Oras epistrofis\n2. Ypologismos Oras apostolis ploiwn\n3. Ypologismos Oras apostolis Rec\n");
		printf("4. Emfanish Trexontwn Dedomenwn\n5. Telos. Emfanisi apotelesmatwn\n"); //menu
		scanf("%d",&tmp);
	
		switch (tmp)
		{
			case 1: stdf = 1;
				ypepst(&epst);
				break;
			case 2: if (stdf) yps(snds,&epst);
				else printf("Return time Not defined, Please run choise 1 first\n");
				break;
			case 3: if (stdf) ypsrc(&rc,&epst);
				else printf("Return time Not defined, Please run choise 1 first\n");
				break;
			case 4: sh(epst,snds,rc);
				break;
			default: printf("Lathos eisagogi\n");
		}
	}

	sh(epst,snds,rc);//ektiposi apotelesmatwn prin tin eksodo

	return EXIT_SUCCESS;
}

int timecmp(const Time t1, const Time t2)
{
	if (t1.ttos() < t2.ttos()) return -1;
	if (t1.ttos() > t2.ttos()) return  1;
	return 0;
}

void ypepst(Time *epst)
{
	Time tmp1,tmp2;
	int a,b,c;
	printf("Insert Server time of the shot (format *:*:*)\n");
	scanf("%d:%d:%d",&a,&b,&c);
	tmp1.set_time(a,b,c);
	printf("Insert Remaining time of the shot (format *:*:*)\n");
	scanf("%d:%d:%d",&a,&b,&c);
	tmp2.set_time(a,b,c);
	*epst = tmp1 + tmp2;
	system("clear");
}
void yps(list mylist,Time *ht)
{
	Time tmp;
	int a,b,c;
	printf("Insert Duration time of the fleet (format *:*:*)\n");
	scanf("%d:%d:%d",&a,&b,&c);
	tmp.set_time(a,b,c);
	mylist.add(*ht - tmp);
	system("clear");
}

void ypsrc(Time *rc,Time *ht)
{
	Time tmp;
	int a,b,c;
	printf("Insert Duration time of the recyclers (format *:*:*)\n");
	scanf("%d:%d:%d",&a,&b,&c);
	tmp.set_time(a,b,c);
	*rc = *ht - tmp;
	system("clear");
}

void sh(Time ht,list mylist, Time rc)
{
	system("clear");
	printf("The hit will be on : ");
	ht.display();
	for ( node *tmp = mylist.head ; tmp != mylist.tail ; tmp = tmp->nxt)
	{
		printf("Fleet # Launches at ");
		(*tmp).val.display();
	}
	printf("Recyclers launch at : ");
	rc.display();
	printf("\n\n");
}