Пример #1
0
void cellphone::display()
{
	cout << "\n" << endl;
	cout << "Details about your phone:" << endl;
	cout <<"Batterylife:     " << getbatterylife() <<" hours" << endl;
	cout <<"Price:         $" << getprice() << endl;
	cout <<"Minutes:        " << getminutes() << endl;
}
Пример #2
0
int main()
{
	attach_init();
	if(!loginok)return 0;
	if(!HAS_PERM(PERM_CHATCLOAK))return 0;
	FILE *fp;
	char buf[80];
	int i,j,l;
	if(!(fp=fopen(gettshirtfile(""),"r")))
		http_fatal("无法打开文件");
	fseek(fp,0,0);
	printf("\"订单编号\",\"用户\",\"订单日期\",\"结算日期\",\"销售代表\",\"地址\",\"电话1\",\"电话2\",\"备注\",");
	for(i=0;i<10;i++)
		printf("\"样式%d\",\"尺码%d\",\"数量%d\",",i+1,i+1,i+1);
	printf("\"计件\",\"计价\"\x0d\x0a");
	for(i=0;;i++)
	{
		if(!(fread(&ts,sizeof(ts),1,fp)))break;
		getdatestring(ts.torder,NA);
		strcpy(buf,datestring);
		*(buf+22)=0;
		printf("\"%d\",\"%s\",\"%s\",",i,ts.userid,buf);
		getdatestring(ts.tapprove,NA);
		strcpy(buf,datestring);
		*(buf+22)=0;
		printf("\"%s\",\"%s\",",(ts.tapprove)?buf:"",ts.approved);
		tsoutput(ts.addr);
		printf(",");
		tsoutput(ts.tel);
		printf(",");
		tsoutput(ts.tel2);
		printf(",");
		tsoutput(ts.memo);
		printf(",");
		for(j=0;j<10;j++)
			printf("\"%d\",\"%d\",\"%d\",",ts.t[j].style,ts.t[j].size,ts.t[j].count);
		printf("\"%d\",\"%.2f\"\x0d\x0a",ts.flag,getprice(ts));
	}
	fclose(fp);
	return 0;
}
Пример #3
0
/* called in hack.c when we pickup an object */
void
addtobill(struct obj *obj)
{
	struct bill_x *bp;

	if(!inshop() ||
	(u.ux == ESHK(shopkeeper)->shk.x && u.uy == ESHK(shopkeeper)->shk.y) ||
	(u.ux == ESHK(shopkeeper)->shd.x && u.uy == ESHK(shopkeeper)->shd.y) ||
		onbill(obj) /* perhaps we threw it away earlier */
	  ) return;
	if(ESHK(shopkeeper)->billct == BILLSZ){
		pline("You got that for free!");
		return;
	}
	bp = &bill[ESHK(shopkeeper)->billct];
	bp->bo_id = obj->o_id;
	bp->bquan = obj->quan;
	bp->useup = 0;
	bp->price = getprice(obj);
	ESHK(shopkeeper)->billct++;
	obj->unpaid = 1;
}
Пример #4
0
/* called in hack.c (or whatever) when we pickup an object */
void addtobill(obj_t *obj)
{
  bill_t *bp;
  eshk_t *eshk = (shopkeeper ? ESHK(shopkeeper) : NULL);
  if (!inshop() ||
      (you.ux == eshk->shk.x && you.uy == eshk->shk.y) ||
      (you.ux == eshk->shd.x && you.uy == eshk->shd.y) ||
      onbill(obj)) /* perhaps we threw it away earlier */
    return;
  eshk = ESHK(shopkeeper);
  if (eshk->billct == BILLSZ) {
    // Well, I guess that's one way to address predefined limitations
    message("You got that for free!");
    return;
  }
  bp = &bill[eshk->billct];
  bp->bo_id = obj->o_id;
  bp->bquantity = obj->quantity;
  bp->useup = false;
  bp->price = getprice(obj);
  eshk->billct++;
  obj->bitflags |= O_IS_UNPAID;
}
Пример #5
0
int Invoice::getInvoiceAmount()
{
	return getquantity() * getprice();
}
Пример #6
0
void
subfrombill(struct obj *obj)
{
	long ltmp;
	int tmp;
	struct obj *otmp;
	struct bill_x *bp;

	if (!inshop() ||
	    (u.ux == ESHK(shopkeeper)->shk.x && u.uy == ESHK(shopkeeper)->shk.y) ||
	    (u.ux == ESHK(shopkeeper)->shd.x && u.uy == ESHK(shopkeeper)->shd.y))
		return;
	if ((bp = onbill(obj)) != NULL) {
		obj->unpaid = 0;
		if (bp->bquan > obj->quan) {
			otmp = newobj(0);
			*otmp = *obj;
			bp->bo_id = otmp->o_id = flags.ident++;
			otmp->quan = (bp->bquan -= obj->quan);
			otmp->owt = 0;	/* superfluous */
			otmp->onamelth = 0;
			bp->useup = 1;
			otmp->nobj = billobjs;
			billobjs = otmp;
			return;
		}
		ESHK(shopkeeper)->billct--;
		*bp = bill[ESHK(shopkeeper)->billct];
		return;
	}
	if (obj->unpaid) {
		pline("%s didn't notice.", Monnam(shopkeeper));
		obj->unpaid = 0;
		return;		/* %% */
	}
	/* he dropped something of his own - probably wants to sell it */
	if (shopkeeper->msleep || shopkeeper->mfroz ||
	    inroom(shopkeeper->mx, shopkeeper->my) != ESHK(shopkeeper)->shoproom)
		return;
	if (ESHK(shopkeeper)->billct == BILLSZ ||
	    ((tmp = shtypes[rooms[ESHK(shopkeeper)->shoproom].rtype - 8]) &&
	     tmp != obj->olet) || strchr("_0", obj->olet)) {
		pline("%s seems not interested.", Monnam(shopkeeper));
		return;
	}
	ltmp = getprice(obj) * obj->quan;
	if (ANGRY(shopkeeper)) {
		ltmp /= 3;
		NOTANGRY(shopkeeper) = 1;
	} else
		ltmp /= 2;
	if (ESHK(shopkeeper)->robbed) {
		if ((ESHK(shopkeeper)->robbed -= ltmp) < 0)
			ESHK(shopkeeper)->robbed = 0;
		pline("Thank you for your contribution to restock this recently plundered shop.");
		return;
	}
	if (ltmp > shopkeeper->mgold)
		ltmp = shopkeeper->mgold;
	pay(-ltmp, shopkeeper);
	if (!ltmp)
		pline("%s gladly accepts %s but cannot pay you at present.",
		      Monnam(shopkeeper), doname(obj));
	else
		pline("You sold %s and got %ld gold piece%s.", doname(obj), ltmp,
		      plur(ltmp));
}
Пример #7
0
void subfrombill(struct obj *obj)
{
  Long ltmp;
  Short tmp;
  obj_t *otmp;
  bill_t *bp;
  eshk_t *eshk = (shopkeeper ? ESHK(shopkeeper) : NULL);
  if (!inshop() ||
      (you.ux == eshk->shk.x && you.uy == eshk->shk.y) ||
      (you.ux == eshk->shd.x && you.uy == eshk->shd.y))
    return;
  if ((bp = onbill(obj)) != 0) {
    obj->bitflags &= ~O_IS_UNPAID;
    if (bp->bquantity > obj->quantity) {
      otmp = (obj_t *) md_malloc(sizeof(obj_t));// newobj(0);
      *otmp = *obj;
      bp->bo_id = otmp->o_id = flags.ident++;
      otmp->quantity = (bp->bquantity -= obj->quantity);
      otmp->owt = 0;	/* superfluous */
      do_name(otmp, NULL); // otmp->onamelth = 0; // Undo name (if any)
      bp->useup = true;
      otmp->nobj = billobjs;
      billobjs = otmp;
      return;
    }
    eshk->billct--;
    *bp = bill[eshk->billct];
    return;
  }
  if (obj->bitflags & O_IS_UNPAID) {
    StrPrintF(ScratchBuffer, "%s didn't notice.", Monnam(shopkeeper));
    message(ScratchBuffer);
    obj->bitflags &= ~O_IS_UNPAID;
    return;		/* %% */
  }
  /* he dropped something of his own - probably wants to sell it */
  if ((shopkeeper->bitflags & (M_IS_ASLEEP | M_IS_FROZEN)) ||
      inroom(shopkeeper->mx,shopkeeper->my) != eshk->shoproom)
    return;
  if (eshk->billct == BILLSZ ||
      ((tmp = shtypes[rooms[eshk->shoproom].rtype-8]) && tmp != obj->olet) ||
      StrChr("_0", obj->olet)) {
    StrPrintF(ScratchBuffer, "%s seems not interested.", Monnam(shopkeeper));
    message(ScratchBuffer);
    return;
  }
  ltmp = getprice(obj) * obj->quantity;
  if (ANGRY(shopkeeper)) {
    ltmp /= 3;
    shopkeeper->bitflags |= M_IS_PEACEFUL; // NOTANGRY(shopkeeper) = 1;
  } else   ltmp /= 2;
  if (eshk->robbed) {
    if ((eshk->robbed -= ltmp) < 0)
      eshk->robbed = 0;
    message("Thank you for your contribution to restock this recently plundered shop.");
    return;
  }
  if (ltmp > shopkeeper->mgold)
    ltmp = shopkeeper->mgold;
  pay(-ltmp, shopkeeper);
  if (!ltmp)
    StrPrintF(ScratchBuffer,
	      "%s gladly accepts %s but cannot pay you at present.",
	      Monnam(shopkeeper), doname(obj));
  else
    StrPrintF(ScratchBuffer,
	      "You sold %s and got %ld gold piece%s",
	      doname(obj), ltmp, (ltmp == 1 ? "." : "s."));
  message(ScratchBuffer);
}