コード例 #1
0
int main(){
	
	 int codigo[NUMEROARTICULOS]={101,102,103,104,105,106};
	 char descripcion[NUMEROARTICULOS][MAXCHAR]={ "Articulo#1", "Articulo#2", "Articulo#3","Articulo#4","Articulo#5", "Articulo#6"};
	 int valor[NUMEROARTICULOS]={300,500,250,100,900,600};
	 char opcion;
	 int new;

	 while(opcion!='q'){
	 setbuf(stdin, NULL);
	 printf("\n\n=================================== \nIngrese \n A para una nueva factura \n B para consultar Articulo \n Q para salir \n");
	 scanf("%c", &opcion);


		 if (opcion=='a' || opcion=='A'){
		 	//Llamado a la funcion para crear una nueva funcion
		 	newBill(codigo, valor , descripcion);
		 } else  if(opcion=='b' || opcion=='B'){
		 	//Llamado a la funcion para buscar un articulo
		 	buscarItem(codigo,  valor, (char (*)[MAXCHAR])descripcion);
		 } else  if(opcion=='q' || opcion=='Q'){
		 	return 0;
		 } else{
		 	 printf("No ingreso una opcion valida \n");
		 }
	
	  }

}
コード例 #2
0
int main(int argc, char *argv[]){
	/*
	int codes[MAXITEMS] = {101,102,103,104,105,106};
	char descriptions[MAXITEMS][MAXCHAR] = {"Articulo#1", "Articulo#2", "Articulo#3","Articulo#4","Articulo#5", "Articulo#6"};
	int values[MAXITEMS]={300,500,250,100,900,600};
	*/
	
	//Se abre el archivo
	printf("argc: %d\n",argc);
	printf("argv: %s\n",argv[1]);

	char *fileName=argv[1];
	FILE *inFile;
	inFile=fopen(fileName,"r");
 	if(inFile==NULL){
		printf("Cannot open file");
	   	exit(EXIT_FAILURE);    
	}
	
	//Se reserva la memoria dinamica
	int numItems;
	numItems=cantItems(inFile);
	str_item *ApItems;
	ApItems= (str_item *)malloc(numItems*sizeof(str_item));
	printf("memoria dinamica cargada\n");

	//Se cargan los datos desde el archivo "items.txt"
	getData(&numItems,ApItems,inFile);


	char option;

	while(option!='q'){

		printf("Ingrese \n a. Nueva factura \n b. Consultar articulo \n c. Ingresar articulo \n q. Salir \n");
		setbuf(stdin, NULL);
		scanf("%c", &option);

		 if (option=='a'){
		 	//Creating a new ticket
		 	newBill(ApItems,argv[2]);
		 } else  if(option=='b'){
		 	//Checking an item
		 	//checkItem(codes, (char (*)[MAXCHAR])descriptions[0], values);
		 } else  if(option=='c'){
		 	//Add new item to list
		 	
		 } else  if(option=='q'){
		 	return 0;
		 } else{
		 	 printf("Opcion no valida\n");
		 }
	}

	//Cierro el fichero
	fclose(inFile);
	
	//Libero el espacio asignado en memoria dinamica
	free(ApItems);
	return 0;
}
コード例 #3
0
ファイル: gamewindow.cpp プロジェクト: jesusega/yoshi_quest
/**Constructor*/
Game::Game(QTimer *t, QString n)
{	
	setFixedSize(500, 500);
	setFocus();
	
	//removes scroll bars
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	
	//creates a new scene and sets it in a fixed location
	gScene = new QGraphicsScene();
	gScene->setSceneRect(0, 0, 500, 500);
	setScene(gScene);
	
	//creates the Pixmaps of all the "things" for their constructors
	yPix = new QPixmap("img/yoshiw2.png");
	bPix = new QPixmap("img/bg.png");
	hPix = new QPixmap("img/heart.png");
	coinPix = new QPixmap("img/coin.png");
	goombaPix = new QPixmap("img/goombaw1.png");
	koopaPix = new QPixmap("img/koopaw1r.png");
	kamekLPix = new QPixmap("img/kamek1.png");
	kamekRPix = new QPixmap("img/kamek21.png");
	billLPix = new QPixmap("img/lbill.png");
	billRPix = new QPixmap("img/rbill.png");
	magicPix = new QPixmap("img/magic.png");
	boltPix = new QPixmap("img/bolt.png");
	windPix = new QPixmap("img/wind.png");
	
	/*creates "things"*/
	//background
	background = new Bg(bPix, 0, 0, 0, 0);
	
	//adds Yoshi (playable character) to list
	yoshi = new Yoshi(yPix, 225, 405, 1, 1);
	things.push_back(yoshi);
	yoshi->setZValue(3);
	
	//coin on stats panel (lava)
	sCoin = new Coin(coinPix, 170, 460, 0, 0);
	sCoin->setZValue(2);
	
	//heart
	heart = new Heart(hPix, 20, 465, 0, 0);
	heart->setZValue(2);
	
	/*create text*/
	//font size
	font.setPixelSize(30);
	fontT.setPixelSize(14);
	
	//word "Score"
	sLabel = new QGraphicsSimpleTextItem("Score: ");
	sLabel->setPos(300, 450);
	sLabel->setFont(fontT);
	sLabel->setZValue(3);
	nameLabel = new QGraphicsSimpleTextItem("Name: ");
	nameLabel->setPos(300, 465);
	nameLabel->setFont(fontT);
	nameLabel->setZValue(3);
	levelLabel = new QGraphicsSimpleTextItem("Level: ");
	levelLabel->setPos(300, 480);
	levelLabel->setFont(fontT);
	levelLabel->setZValue(3);
	
	//actual score value
	score = 0;
	QString temp = QString::number(score);
	sAmount = new QGraphicsSimpleTextItem(temp);
	sAmount->setPos(400, 450);
	sAmount->setFont(fontT);
	sAmount->setZValue(3);
	
	//lives
	lives = 3;
	temp = QString::number(lives);
	lAmount = new QGraphicsSimpleTextItem(temp);
	lAmount->setPos(70, 460);
	lAmount->setFont(font);
	lAmount->setZValue(3);
	
	//number of coins collected
	nCoins = 0;
	temp = QString::number(nCoins);
	cAmount = new QGraphicsSimpleTextItem(temp);
	cAmount->setPos(210, 460);
	cAmount->setFont(font);
	cAmount->setZValue(2);
	
	//level
	levelCnt = 1;
	temp = QString::number(levelCnt);
	levelAmount = new QGraphicsSimpleTextItem(temp);
	levelAmount->setPos(400, 480);
	levelAmount->setFont(fontT);
	levelAmount->setZValue(2);
	gScene->addItem(levelAmount);
	
	//name
	nLabel = new QGraphicsSimpleTextItem(n);
	nLabel->setPos(400, 465);
	nLabel->setFont(fontT);
	nLabel->setZValue(2);
	
	
	//now barrage the scene with the items!
	gScene->addItem(background);
	gScene->addItem(heart);
	gScene->addItem(sCoin);
	gScene->addItem(sLabel);
	gScene->addItem(nLabel);
	gScene->addItem(sAmount);
	gScene->addItem(lAmount);
	gScene->addItem(cAmount);
	gScene->addItem(nameLabel);
	gScene->addItem(levelLabel);
	for(int k=1; k<things.size(); k++)
		gScene->addItem(things[k]);
	
	gScene->addItem(yoshi);
	
	//timers
	timer = t;
	
	//counters
	goombaCnt = 0;
	koopaCnt = 0;
	kamekCnt = 0;
	billCnt = 0;
	coinCnt = 0;
	heartCnt = 0;
	goombaMax = 150;
	koopaMax = 200;
	kamekMax = 300;
	billMax = 400;
	coinMax = 200;
	heartMax = 450;
	yoshiJCnt = 0;
	spawnCnt = 100;
	timeCnt = 0;
	interval = timer->interval();
	velx = 1;
	vely = 1;
	boolMagic = false;
	overG = false;
	
	//connect to slot functions
	connect(timer, SIGNAL(timeout()), this, SLOT(animate()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newCoin()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newGoomba()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newKoopa()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newKamek()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newBill()));
	connect(timer, SIGNAL(timeout()), this, SLOT(newHeart()));
	connect(timer, SIGNAL(timeout()), this, SLOT(offScreen()));
}