question archive A music shop sells CDs, DVDs, magazines and books

A music shop sells CDs, DVDs, magazines and books

Subject:Computer SciencePrice:2.87 Bought7

A music shop sells CDs, DVDs, magazines and books. It is in need of a stock management system ( in C++) to maintain stock records with a text (command line) menu with options to allow the user to perform the following functionality: sell items, restock items (increase stock quantity),add new items, update stock quantity (correct stock levels), view a report of sales and it should also be possible to load and save the stock data to/from a file. 

 

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Answer:

#include<graphics.h>
#include <fstream.h>
#include <conio.h>
#include<iostream.h>
#include<iomanip.h>
#include <string.h>
#include <stdlib.h>
#include<dos.h>
#include<stdio.h>
#include<ctype.h>
#define indexfile "index.txt"
///////////////////////////////////////////////////////////////////////
fstream indfile;
int i,indsize;
int isAlpha(char ch)
{
if(isalpha(ch) || ch==' ')
    return 1;
 else
    return 0;
}

int checkShare_ID(char share_ID[])//check if share_ID is valid
{
if((strlen(share_ID)==4)&&isdigit(share_ID[3])&&(isdigit(share_ID[2]))&&(isalpha(share_ID[0]))&&(isalpha(share_ID[1])))
 return 1;
else
 return 0;
}
/*int checkBlood_type_id(char Blood_type_id[])//check if Blood_type_id is valid
{
if((strlen(Blood_type_id)==2&&isdigit(Blood_type_id[0])&&isdigit(Blood_type_id[1]))&&(Blood_type_id[1]>='1')&&(Blood_type_id[1]<='8'))
return 1;
else
return 0;
}
int checkBlood_type(char Blood_type[])
{
     int valid=0;
if(strcmpi(Blood_type,"a+")==0||strcmpi(Blood_type,"a-")==0||strcmpi(Blood_type,"b+")==0||strcmpi(Blood_type,"b-")==0||strcmpi(Blood_type,"ab+")==0||strcmpi(Blood_type,"ab-")==0||strcmpi(Blood_type,"o+")==0||strcmpi(Blood_type,"o-")==0)
 valid=1;
   return valid;
}
int checkstring(char *str)
{
int valid=1,i;
for(i=0;i<strlen(str);i++)
if(isAlpha(str[i])==0)
{
     valid=0;
     break;
 }
 return(valid);
} */


class block  // class for block
{
  public:
 char keys[4][11];
 block *link;
 int disp[4];
 int cnt;
 block();
 ~block(){}
 void split();
 void merge();
};
/*************************************************/
class SSET  // class for sequence set
{
  public:
 typedef block *BK;
 SSET();
 ~SSET(){}
 void create();
 int Insert(char*,int);
 void del(char*);
 block *FindNode(char*);
 void display();
};
/**************************************************/
class node // class for btree node
{
  public:
 char keys[4][11];
 node *dptrs[4];
 node *uptr;
 block *ptr[4];
 int cnt;
 node();
 ~node(){}
 int isLeaf();
 void split(node *,node *,node *);
};
/**************************************************/
class btree     // class for btree
{
  public:
 btree();
 int insert(char*,block *);
 node* findLeaf(char*,int&);
 block *search(char*,int&);
 void create();
 void dis(node*);
 ~btree(){}
 node *root;
};
/************************************************/
class shares  // class for Blood_bank record
{
  public:
 char share_ID[5],cust_name[20],comp_name[20],share_value[20],no_of_shares[20];
 /* char Blood_bank_location[15];
  char Blood_bank_address[15];
  char Blood_type_id[4];
  char Donor_name[20];
  char Blood_type[5];
  char Donor_phone[15];
  char Date[10];  */
  //int share_value,no_of_shares;

 void Clear();
 int Unpack(fstream&);
 int Pack(fstream&);
 void Input();
 void Display();
 ~shares(){}
 void Assign(shares&);
 void seqdisp();
};
//class IOBUF: clearing the buffer,
//parent class for varlen and delmfld buffer classes
class iobuf
{
protected:
 char Buffer[100];
 int BufSiz;
public:
  void Clear();
  virtual int Read(fstream&)=0;
  virtual int Write(fstream&)=0;
  virtual int Pack(shares&,fstream&)=0;
  virtual int Unpack(shares&,fstream&)=0;
};
//varlen: defines read & write operation on files
class varlen : public iobuf
{
  public:
  int Read(fstream&);
  int Write(fstream&);
};
//delmfld: defines pack & unpack operations for the buffer
class delmfld : public varlen
{
public:
  int Pack(shares&,fstream&);
  int Unpack(shares&,fstream&);
};

Related Questions