⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 item.cpp

📁 1、 模拟一间公司(有普通工人、经理、销售员、计时工人和计件工人)的雇员月工资单管理系统
💻 CPP
字号:
#include <assert.h>
#include <conio.h>
#include <graphics.h>
#include <string.h>
#include "item.h"
extern int changeCode(char);
Item *Item::first=0;
Item *Item::end=0;
Item::Item(int tx1,int ty1,int tx2,int ty2,int ttColor,int trColor,int tfColor,char *pText,POINT p)
{
  x1=tx1;
  x2=tx2;
  y1=ty1;
  y2=ty2;
  fColor=tfColor;
  rColor=trColor;
  tColor=ttColor;
  bkColor=fColor;
  text=new char[strlen(pText)+1];
  assert(text!=0);
  strcpy(text,pText);
  word=*pText;
  code=changeCode(word);
  pointTo=p;
  if(first==0)
    first=this;
  else
    end->next=this;
    end=this;
    end->next=0;
}

Item::~Item()
{
if(first==this)
  first=this->next;
else
  for(Item *p=first;p;p=p->next)
  if(p->next==this) p->next=this->next;
delete text;
}

Item *Item::getNext(){return next;}

POINT Item::getPointTo(){return pointTo;}

Item* Item::search(int key,Item *p,Item *pb)
{
  for(;p;p=p->next)
  {
    if(p->code==key) {pb->resetBK();pb=p;pb->changeBK(7);(pb->pointTo)();break;}
  }
  return pb;
}

Item *Item::getFirst()
{
  Item *p=first;
  first=0;
  return p;
}

void Item::changeBK(int c)
{
  bkColor=c;
  drawItem();
};

void Item::resetBK()
{
  bkColor=fColor;
  drawItem();
};

void Item::drawItem()
{
  int midY=(y1+y2)/2;
  setcolor(rColor);
  rectangle(x1,y1,x2,y2);
  setfillstyle(1,bkColor);
  floodfill(x1+2,y1+2,rColor);
  setcolor(tColor);
  settextjustify(LEFT_TEXT,CENTER_TEXT);
  outtextxy(x1+10,midY,text);
  char t[2];
  t[0]=word;
  t[1]='\0';
  setcolor(LIGHTRED);
  outtextxy(x1+10,midY,t);
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -