Page 515 - Computer science 868 Class 12
P. 515
53 case 2:
54 n=ob.popvalue();
55 if(n==-9999)
56 System.out.println("Queue Underflow");
57 else
58 System.out.println(n+" deleted from queue");
59 break;
60 case 3:
61 ob.disp();
62 break;
63 default: System.out.println("Exit");
64 }
65 } while(ch>=1&&ch<=3);
66 }
67 }
Program 4 A linear data structure enables the user to add an address from rear end and remove address
from front. Define a class Diary with the following details. [ISC 2019]
Class name : Diary
Data Members/Instance variables
Q[] : an array to store the addresses
size : to store the maximum capacity of the array
start : to point to the index of the front end
end : to point to the index of the rear end
Member Functions
Diary(int max) : constructor to initialise the data members size = max, start = 0
and end = 0
void pushadd(String n) : to add the address in the diary from the rear end if possible,
otherwise display the message “NO SPACE”
String popadd() : to remove and return the address from the front end of the
diary if any, else returns “?????”
void show () : to display all the addresses in the diary
Specify the class Diary giving details of the functions void pushadd(String) and String popadd()
and void show().
1 import java.util.*;
2 class Diary
3 { String Q[];
4 int size,start,end;
5 Diary(int max)//constructor
513
Data Structures 513

