In the example illustrated in Figure 132 state which of the
In the example illustrated in Figure 13.2, state which of the eight BLP rules are invoked for each action in the scenario.
Solution
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class stock
{
char author[50];
char title[50];
char pub[50];
double price;
int numcopies;
public:
stock();
int access_title(char a[]);
void input();
void getdata(int);
};
stock::stock()
{
char author[50]={\"abc\"};
char title[50]={\"efg\"};
char pub[50]={\"hij\"};
price=500;
numcopies=50;
}
int stock::access_title(char a[])
{
if(strcmp(title,a))
return 0;
else return 1;
}
void stock::getdata(int num)
{
if(numcopies>=num)
cout<<\"\ Cost of \"<<num<<\" books is Rs. \"<<(price*num);
else
cout<<\"\ Sorry! These many copies are unavailable!\";
}
void stock::input()
{
cout<<\"\ Title: \";
gets(title);
cout<<\"\ Author:\";
gets(author);
cout<<\"\ Publisher:\";
gets(pub);
cout<<\"\ Prices:\";
cin>>price;
cout<<\"\ copies available:\";
cin>>numcopies;
}
void main()
{
clrscr();
stock obj[2];
int n;
char ttle[50];
cout<<\"Enter details of 3 books\";
for(int i=0;i<2;++i)
obj[i].input();
cout<<endl;
cout<<\"\ Enter title of required book\ \";
gets(ttle);
for(i=0;i<2;i++)
{
if(obj[i].access_title(ttle))
{
cout<<\"\ How many copies? \";
cin>>n;
obj[i].getdata(n);
}
else
cout<<\"\ Book unavailable\";
}
getch();
}


