Thursday, 28 May 2020
Tuesday, 26 May 2020
How to create a Menu driven Program in Python
How to create a Menu driven Program in Python..
Step 1. Open your python command prompt.
Step 2. Write the following code into it.
Step 3. Execute it / Test the output for various inputs.
Step 4. Now move towards the study parts of python like how to declare and define function in python.
Step 5. To study function more in detail please click on the following link
The code to write in Step 2 are as follows:
Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Ana
conda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def mainMenu():
... print("1. Adition")
... print("2. Substraction")
... print("3. Exit")
... choice=int(input("Enter u r choice"))
... if choice==1:
... add()
... elif choice==2:
File "<stdin>", line 8
elif choice==2:
^
SyntaxError: invalid syntax Note: indentation of code is too much important in python otherwise you will get error like this.
# Following is the code of main function in python.
>>> def mainMenu():
... print("1. Adition")
... print("2. Substraction")
... print("3. Exit")
... choice=int(input("Enter u r choice"))
... if choice==1:
... add() #when choice is equals to 1 we call add() function from mainMenu()
... elif choice==2:
... sub() #when choice is equals to 2 we call sub() function from mainMenu()
... elif choice==3:
... exit #when choice is equals to 3 we call exit function from mainMenu()
... else:
... print("Invalid choice, Enter valid choice1-3")
... mainMenu()
...# to come out from function press two times Enter key.
# To call mainMenu function for execution.
>>> mainMenu()
1. Adition
2. Substraction
3. Exit
Enter u r choice5 # here we are testing our code for invalid input.
Invalid choice, Enter valid choice1-3
1. Adition
2. Substraction
3. Exit
Enter u r choice3 # for valid inputs its works fine
# Definition of add() function that is actual logic of addition function how it behaves after calling.
>>> def add():
... print("Enter no1:")
... x=int(input())
... y=int(input("Enter no2:"))
... z=x+y
... print("The add is:",z)
... mainMenu()
...
>>> mainMenu() # space is not allowed while calling function
File "<stdin>", line 1
mainMenu()
^
IndentationError: unexpected indent
>>> mainMenu()
1. Adition
2. Substraction
3. Exit
Enter u r choice1 #Execution or calling of sub() function
Enter no1:
2
Enter no2:2
The add is: 4
1. Adition
2. Substraction
3. Exit
Enter u r choice4
Invalid choice, Enter valid choice1-3
1. Adition
2. Substraction
3. Exit
Enter u r choice3
# Definition of sub() function that is actual logic of substraction function how it behaves after calling.
>>> def sub():
... a=int(input("enter no1"))
... b=int(input("enter no2"))
... print("The sub is:",a-b)
... mainMenu()
...
>>> mainMenu()
1. Adition
2. Substraction
3. Exit
Enter u r choice2 #Execution or calling of sub() function
enter no120
enter no210
The sub is: 10
1. Adition
2. Substraction
3. Exit
Enter u r choice3
>>>
Monday, 25 May 2020
Syllabus: (2019 Course) Fundamentals of Data Structures (FDS)
SECOND YEAR COMPUTER ENGINEERING (2019 COURSE) A. Y : 2020-2021
Note: ROUGH SYLLABUS YET NOT FINALISE:
Savitribai Phule Pune University Second Year of Computer Engineering (2019 Course)
Credit: 03
Examination Scheme: Mid_Semester(TH): 30 Marks
End_Semester(TH): 70 Marks
Unit I Introduction to Algorithm and Data Structures (07 Hrs)
Unit II Linear Data Structure Using Sequential Organisation (07 Hrs)
Unit III Searching and Sorting (06 Hrs)
Unit IV Linked List (07 Hrs)
Note: ROUGH SYLLABUS YET NOT FINALISE:
Savitribai Phule Pune University Second Year of Computer Engineering (2019 Course)
210242: Fundamentals of Data Structures
Teaching Scheme: TH: 03 Hours/WeekCredit: 03
Examination Scheme: Mid_Semester(TH): 30 Marks
End_Semester(TH): 70 Marks
Unit I Introduction to Algorithm and Data Structures (07 Hrs)
Introduction: From Problem to Data Structure (Problem, Logic, Algorithm, and Data Structure). Data Structures: Data, Information, Knowledge, and Data structure, Abstract Data Types (ADT), Data Structure Classification (Linear and Non-linear, Static and Dynamic, Persistent and Ephemeral data structures) Algorithms: Problem Solving, Introduction to algorithm, Characteristics of algorithm, Algorithm design tools: Pseudo-code and flowchart Complexity of algorithm: Space complexity, Time complexity, Asymptotic notation- Big-O, Theta and Omega, Finding complexity using step count method, Analysis of programming constructs-Linear, Quadratic, Cubic, Logarithmic.
Algorithmic Strategies- Introduction to algorithm design strategies- Divide and Conquer, and Greedy strategy.
#Exemplar/Case Studies
Multiplication technique by the mathematician Carl Friedrich Gauss and Karatsuba algorithm for fast multiplication.
Unit II Linear Data Structure Using Sequential Organisation (07 Hrs)
Concept of Sequential Organisation, Overview of Array, Array as an Abstract Data Type, Operations on Array, Merging of two arrays, Storage Representation and their Address Calculation: Row major and Column Major, Multidimensional Arrays: Two-dimensional arrays, n-dimensional arrays. Concept of Ordered List, Single Variable Polynomial: Representation using arrays, Polynomial as array of structure, Polynomial addition, Polynomial multiplication. Sparse Matrix: Sparse matrix representation using array, Sparse matrix addition, Transpose of sparse matrix- Simple and Fast Transpose, Time and Space tradeoff.
#Exemplar/Case Studies Study use of sparse matrix in Social Networks and Maps. Study how Economists use polynomials to model economic growth patterns, how medical researchers use them to describe the behaviour of Covid-19 virus.
Unit III Searching and Sorting (06 Hrs)
Searching: Search Techniques-Sequential Search/Linear Search, Variant of Sequential Search- Sentinel Search, Binary Search, Fibonacci Search, and Indexed Sequential Search. Sorting: Types of Sorting-Internal and External Sorting, General Sort Concepts-Sort Order, Stability, Efficiency, and Number of Passes, Comparison Based Sorting Methods-Bubble Sort, Insertion Sort, Selection Sort, Quick Sort, Shell Sort, Non-comparison Based Sorting Methods-Radix Sort, Counting Sort, and Bucket Sort, Comparison of All Sorting Methods and their complexities.
#Exemplar/Case Studies Use of Fibonacci search in non-uniform access memory storage and in Optimization of Unimodal Functions. Timsort as a hybrid stable sorting algorithm
Unit IV Linked List (07 Hrs)
Introduction to Static and Dynamic Memory Allocation, Linked List: Introduction, of Linked Lists, Realization of linked list using dynamic memory management, operations, Linked List as ADT, Types of Linked List: singly linked, linear and Circular Linked Lists, Doubly Linked List, Doubly Circular Linked List, Primitive Operations on Linked List-Create, Traverse, Search, Insert, Delete, Sort, Concatenate. Polynomial Manipulations-Polynomial addition. Generalized Linked List (GLL) concept, Representation of Polynomial using GLL.
#Exemplar/Case Studies Garbage Collection.
Unit V Stack (07 Hrs)
Basic concept, stack Abstract Data Type, Representation of Stacks Using Sequential Organization, stack operations, Multiple Stacks, Applications of Stack- Expression Evaluation and Conversion, Polish notation and expression conversion, Need for prefix and postfix expressions, Postfix expression evaluation, Linked Stack and Operations. Recursion- concept, variants of recursion- direct, indirect, tail and tree, Backtracking algorithmic strategy, use of stack in backtracking. #Exemplar/Case Studies Android- multiple tasks/multiple activities and back-stack , Tower of Hanoi, 4 Queens problem.
Unit VI Queue (06 Hrs)
Basic concept, Queue as Abstract Data Type, Representation of Queue using Sequential organization, Queue Operations, Circular Queue and its advantages, Multi-queues, Linked Queue and Operations. Deque-Basic concept, types (Input restricted and Output restricted), Priority Queue- Basic concept, types(Ascending and Descending).
#Exemplar/Case Studies Priority queue in bandwidth management.
Learning Resources
Text Books:
Horowitz and Sahani―Fundamentals of Data Structures in C++, University Press, ISBN 10: 0716782928 ISBN 13: 9780716782926.
Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser, Data Structures and Algorithms in Python, Wiley Publication, ISBN: 978-1-118-29027-9
Reference Books:
1. Brassard & Bratley ―Fundamentals of Algorithmic Prentice Hall India/Pearson Education, ISBN 13-9788120311312.
2. Allen Downey, Jeffery Elkner, Chris Meyers-How to think like a Computer Scientist: Learning with Python, Dreamtech Press, ISBN:9789351198147.
3. R. Gillberg, B. Forouzn ―Data Structures: A Pseudo code approach with C, Cenage Learning, ISBN: 9788131503140.
4. M. Weiss―Data Structures and Algorithm Analysis in C++, 2nd edition, Pearson Education, 2002, ISBN-81-7808-670-0.
Other:
Know Thy Complexities! (https://www.bigocheatsheet.com/) (https://github.com/RehanSaeed/.NET-Big-O-Algorithm-Complexity-Cheat-Sheet)
Data Structure Visualizations (https://www.cs.usfca.edu/~galles/visualization/Algorithms.html)
Monday, 30 September 2019
Step by Step guide to connect login page with database using HTML, CSS, PHP, MySQL
Problem statement:
Design HTML pages for Registration/login and connect that pages with database also generate
several reports as per the application requirement in your project.
Objective:
1. create login and registration page.
1.1 when user enters username and password check either it is valid display the message login succesfull..or if not.
1.2 if it is not valid store his information in database and make him valid and again perform the
login if login successfull display the appropriate message login successfull.
Solution:
A. First install XAMPP server on your machine as per the machine operating system and also
download sublime Text editor. (Errors may be like this:>api-ms-win-crt-runtime-|1-1-0.dll
reinstall)
B. Start Apache and MySQL services.
C. Go to browser and type localhost/phpmyadmin
D. Create database eg:login after that Create table eg:users inside this database and insert
one row value in it like testuser and password testuserpass.
E. Create one folder inside C:/Program file/XAMPP --> htdoc ---> create your project folder like
LoginProj
F. inside this LoginProj folder store three files in it. 1.login.php 2. style.css 3.process.php
G. Now inside login.php write the code of login form design with form action=process.php and
method="POST"
H. After that go to Browser and check either login form design is proper or not so for that type
localhost/LoginProj/login.php.
I. When we click on login button it take us to process.php page.
J. Now go to style.css page and write all code neccessary for login form design.
K. Now go to process.php page and write code
//1.to get values passes from form in login.php file.
<?php
$username=$_POST['username']; //username must be id="username" value in login.php file
$password=$_POST['password']; //password must be id="password" value in login.php file
//2.to prevent mysql injection. Ref:https://www.youtube.com/watch?v=arqv2YVp_3E
$username=stripcslashes($username);
$password=stripcslashes($password);
$username=mysql_real_escape_string($username);
$password=mysql_real_escape_string($password);
//3.connect to the server and select database.
mysql_connect("localhost","root","");
mysql_select_db("login");
//4.query the database for user.
$result=mysql_query("select * from users where username = '$username' and password =
'$password'") or die("Failed to query database" .mysql_error());
$row = mysql_fetch_array($result);
if($row['username']==$username && $row['password']==$password)
{
echo "Login success!!! Welcome".$row['username'];
}
else
{
echo "Failed to login...";
}
?>
L. Now go to browser and type localhost/LoginProj/login.php. enter user and password and click on login button appropriate message gets displayed.
/*HERE IS THE CODE FOR ALL PAGES*/
1. login.php
<html>
<head>
<title> Login and Registration Form Design</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="login-page">
<div class="form">
<form class="register-form">
<input type="text" placeholder="username" name="useri" id="user"/>
<input type="text" placeholder="password" name="pasw" id="pass"/>
<input type="text" placeholder="email id" name="emaill" id="email"/>
<button>Create</button>
<p class="message"> Already Registered?<a href="#"> Login</a></p>
</form>
<form class="login-form" action="process.php" method="POST">
<input type="text" placeholder="username" id="username" name="usr"/>
<input type="password" placeholder="password" id="password" name="passw"/>
<button>Login</button>
<p class="message">Not Registered?<a href="#"> Register</a></p>
</div>
</div>
<script src='https://code.jquery.com/jquery-3.4.1.min.js'>
</script>
<script>
$('.message a').click(function(){
$('form').animate({height:"toggle",opacity:"toggle"},"slow");
});
</script>
</body>
</html>
2. style.css
body{
background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.6)),url(Lighthouse.jpg);
height:100vh;
background-size:cover;
background-position:center;
}
.login-page{
width:360px;
padding:10% 0 0;
margin:auto;
}
.form{
position:relative;
z-index:1;
background:rgba(7,40,195,0.8);
max-width:360px;
margin:0 auto 100px;
padding:45px;
text-align:center;
}
.form input{
font family:"Roboto",sans-serif;
outline:1;
background:#f2f2f2;
width:100%;
border:0;
margin:0 0 15px;
padding:15px;
box-sizing:border-box;
font-size:14px;
}
.form button{
font family:"Roboto",sans-serif;
text-transform:uppercase;
outline:0;
background:#4cAF50;
width:100%;
border:0;
padding:15px;
color:#ffffff;
font-size:14px;
cursor:pointer;
}
.form button:hover,.form button:active{
background:#43A047;
}
.form .message{
margin:15px 0 0;
color:aliceblue;
font-size:12px;
}
.form .message a{
color:#4CAF50;
text-decoration:none;
}
.form .register-form{
display:none;
}
3. process.php
//query to the database
$sql="select * from users where username = '$uname' and password = '$password'";
$result=mysqli_query($con,$sql);
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
else
{
$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
if($row['username']==$uname && $row['password']==$password)
{
echo "Login success!!! Welcome ".$row['username'];
}
else
{
echo "Failed to login...";
}
}
mysqli_close($con);
?>
Design HTML pages for Registration/login and connect that pages with database also generate
several reports as per the application requirement in your project.
Objective:
1. create login and registration page.
1.1 when user enters username and password check either it is valid display the message login succesfull..or if not.
1.2 if it is not valid store his information in database and make him valid and again perform the
login if login successfull display the appropriate message login successfull.
Solution:
A. First install XAMPP server on your machine as per the machine operating system and also
download sublime Text editor. (Errors may be like this:>api-ms-win-crt-runtime-|1-1-0.dll
reinstall)
B. Start Apache and MySQL services.
C. Go to browser and type localhost/phpmyadmin
D. Create database eg:login after that Create table eg:users inside this database and insert
one row value in it like testuser and password testuserpass.
E. Create one folder inside C:/Program file/XAMPP --> htdoc ---> create your project folder like
LoginProj
F. inside this LoginProj folder store three files in it. 1.login.php 2. style.css 3.process.php
G. Now inside login.php write the code of login form design with form action=process.php and
method="POST"
H. After that go to Browser and check either login form design is proper or not so for that type
localhost/LoginProj/login.php.
I. When we click on login button it take us to process.php page.
J. Now go to style.css page and write all code neccessary for login form design.
K. Now go to process.php page and write code
//1.to get values passes from form in login.php file.
<?php
$username=$_POST['username']; //username must be id="username" value in login.php file
$password=$_POST['password']; //password must be id="password" value in login.php file
//2.to prevent mysql injection. Ref:https://www.youtube.com/watch?v=arqv2YVp_3E
$username=stripcslashes($username);
$password=stripcslashes($password);
$username=mysql_real_escape_string($username);
$password=mysql_real_escape_string($password);
//3.connect to the server and select database.
mysql_connect("localhost","root","");
mysql_select_db("login");
//4.query the database for user.
$result=mysql_query("select * from users where username = '$username' and password =
'$password'") or die("Failed to query database" .mysql_error());
$row = mysql_fetch_array($result);
if($row['username']==$username && $row['password']==$password)
{
echo "Login success!!! Welcome".$row['username'];
}
else
{
echo "Failed to login...";
}
?>
L. Now go to browser and type localhost/LoginProj/login.php. enter user and password and click on login button appropriate message gets displayed.
/*HERE IS THE CODE FOR ALL PAGES*/
1. login.php
<html>
<head>
<title> Login and Registration Form Design</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="login-page">
<div class="form">
<form class="register-form">
<input type="text" placeholder="username" name="useri" id="user"/>
<input type="text" placeholder="password" name="pasw" id="pass"/>
<input type="text" placeholder="email id" name="emaill" id="email"/>
<button>Create</button>
<p class="message"> Already Registered?<a href="#"> Login</a></p>
</form>
<form class="login-form" action="process.php" method="POST">
<input type="text" placeholder="username" id="username" name="usr"/>
<input type="password" placeholder="password" id="password" name="passw"/>
<button>Login</button>
<p class="message">Not Registered?<a href="#"> Register</a></p>
</div>
</div>
<script src='https://code.jquery.com/jquery-3.4.1.min.js'>
</script>
<script>
$('.message a').click(function(){
$('form').animate({height:"toggle",opacity:"toggle"},"slow");
});
</script>
</body>
</html>
2. style.css
body{
background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.6)),url(Lighthouse.jpg);
height:100vh;
background-size:cover;
background-position:center;
}
.login-page{
width:360px;
padding:10% 0 0;
margin:auto;
}
.form{
position:relative;
z-index:1;
background:rgba(7,40,195,0.8);
max-width:360px;
margin:0 auto 100px;
padding:45px;
text-align:center;
}
.form input{
font family:"Roboto",sans-serif;
outline:1;
background:#f2f2f2;
width:100%;
border:0;
margin:0 0 15px;
padding:15px;
box-sizing:border-box;
font-size:14px;
}
.form button{
font family:"Roboto",sans-serif;
text-transform:uppercase;
outline:0;
background:#4cAF50;
width:100%;
border:0;
padding:15px;
color:#ffffff;
font-size:14px;
cursor:pointer;
}
.form button:hover,.form button:active{
background:#43A047;
}
.form .message{
margin:15px 0 0;
color:aliceblue;
font-size:12px;
}
.form .message a{
color:#4CAF50;
text-decoration:none;
}
.form .register-form{
display:none;
}
3. process.php
<?php
$con=mysqli_connect("localhost","root","","login");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// escape variables for security
$uname = mysqli_real_escape_string($con, $_POST['usr']);
$password = mysqli_real_escape_string($con, $_POST['passw']);
$con=mysqli_connect("localhost","root","","login");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// escape variables for security
$uname = mysqli_real_escape_string($con, $_POST['usr']);
$password = mysqli_real_escape_string($con, $_POST['passw']);
//query to the database
$sql="select * from users where username = '$uname' and password = '$password'";
$result=mysqli_query($con,$sql);
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
else
{
$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
if($row['username']==$uname && $row['password']==$password)
{
echo "Login success!!! Welcome ".$row['username'];
}
else
{
echo "Failed to login...";
}
}
mysqli_close($con);
?>
Tuesday, 13 August 2019
SE COMP A.Y 2019-20 GROUP B CINEMAX ASSIGNMENT MODIFIED
//============================================================================
// Name : cinemax.cpp
// Author : NitinShivale
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
class cinemax
{
cinemax *next;
cinemax *prev;
cinemax *rows[10]; //data members
string mname;
long mobno;
int flag;
int seatno;
public:
cinemax() //constructor..to initialize the data memeber and rows array.
{
flag=0;
mobno=0;
seatno=0;
next=prev=NULL;
for(int i=0;i<10;i++)
{
rows[i]=NULL;
}
}
void show();
void showSeat(); //member Functions
void createTheater();
}; //end of class
//This show() function only displays the status of rows i:e Array of pointer.
void cinemax::show()
{
for(int i=0;i<10;i++)
{
cout<<"|"<<rows[i]<<"|-> "<<"\n\n";
}
}
//This showSeat() function displays the memory map of theater after creation of theater...
void cinemax::showSeat()
{
cinemax *temp;
for(int i=0;i<10;i++)
{
cout<<"|"<<rows[i]<<"|-> ";
temp=rows[i];
for(int j=0;j<7;j++)
{
cout<<"|"<<temp->prev<<"|"<<temp->seatno<<"|"<<temp->flag<<"|"<<temp->mname<<"|"<<temp->mobno<<"|"<<temp->next<<"|<-->";
temp=temp->next;
}
cout<<"\n\n";
}
}
//This createTheater() function creates the 10 rows and 7 seats of Theater by using Doubly Circular Linked List.
void cinemax::createTheater()
{
cinemax *p,*temp,*head,*p1;
head=p=p1=temp=NULL;
int i,j;
//code for to create the ten rows....
for(i=0;i<10;i++)
{
p=new cinemax;
p->flag=0;
p->seatno=1;
p->mname="NULL"; //code belongs to first node of each row
p->mobno=0;
p->next=p;
p->prev=p;
rows[i]=p;
temp=p;
head=temp;
//code for to create six seats....
for(j=1;j<7;j++)
{
p1=new cinemax;
p1->flag=0;
p1->seatno=j+1;
p1->mname="NULL"; //assuming that flag zero, mob no zero and movie name i:e mname NULL means seat is not booked yet..initial state of seat.
p1->mobno=0;
p1->next=temp->next;
p1->prev=temp;
temp->next=p1;
head->prev=p1;
temp=p1;
}
}
}
//The program execution starts from main() function.
int main() {
cout << "!!!Welcome To Cinemax Theater!!!" << endl;
cinemax c1; //object c1 creation of cinemax theater to call all the member functions.
int ch;
do
{
cout<<"1.Show Rows Status Before Creation of Theater\n"; //Menu for user to display and operate accordingly..
cout<<"2.Show Rows Status After Creation of Theater\n";
cout<<"3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:\n";
cout<<"4.Show Seat Vacancy in Theater...\n";
cout<<"5.Book My Show..\n";
cout<<"6.Cancel My Show...\n";
cout<<"\nEnter your Choice...: ";
cin>>ch;
switch(ch)
{
case 1:cout<<"\n\nBefore Creation of Theater...\n";
c1.show();
break;
case 2:c1.createTheater(); //member function calling
cout<<"\n\nAfter Theater Creation...\n";
c1.show();
break;
case 3:cout<<"\n After Seat creation of Theater....\n";
c1.showSeat();
break;
case 4:cout<<"/* under process */\n";break;
case 5:cout<<"/* under process */\n";break;
case 6:cout<<"/* under process */\n";break;
}//end of switch case
}while(ch!=7); //end of do while loop.
cout<<"\n\n Thank You so much Visit Again....\n";
return 0;
}//end of main() function
/** ======== OUTPUT OF CINEMAX THEATER =======================
*!!!Welcome To Cinemax Theater!!!
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 1
Before Creation of Theater...
|0|->
|0|->
|0|->
|0|->
|0|->
|0|->
|0|->
|0|->
|0|->
|0|->
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...:2
After Theater Creation...
|0xd48010|->
|0xd484e0|->
|0xd489b0|->
|0xd48e80|->
|0xd49350|->
|0xd49820|->
|0xd49cf0|->
|0xd4a1c0|->
|0xd4a690|->
|0xd4ab60|->
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 3
Enter your Choice...: 3
After Seat creation of Theater....
|0xd48010|-> |0xd48430|1|0|NULL|0|0xd480c0|<-->|0xd48010|2|0|NULL|0|0xd48170|<-->|0xd480c0|3|0|NULL|0|0xd48220|<-->|0xd48170|4|0|NULL|0|0xd482d0|<-->|0xd48220|5|0|NULL|0|0xd48380|<-->|0xd482d0|6|0|NULL|0|0xd48430|<-->|0xd48380|7|0|NULL|0|0xd48010|<-->
|0xd484e0|-> |0xd48900|1|0|NULL|0|0xd48590|<-->|0xd484e0|2|0|NULL|0|0xd48640|<-->|0xd48590|3|0|NULL|0|0xd486f0|<-->|0xd48640|4|0|NULL|0|0xd487a0|<-->|0xd486f0|5|0|NULL|0|0xd48850|<-->|0xd487a0|6|0|NULL|0|0xd48900|<-->|0xd48850|7|0|NULL|0|0xd484e0|<-->
|0xd489b0|-> |0xd48dd0|1|0|NULL|0|0xd48a60|<-->|0xd489b0|2|0|NULL|0|0xd48b10|<-->|0xd48a60|3|0|NULL|0|0xd48bc0|<-->|0xd48b10|4|0|NULL|0|0xd48c70|<-->|0xd48bc0|5|0|NULL|0|0xd48d20|<-->|0xd48c70|6|0|NULL|0|0xd48dd0|<-->|0xd48d20|7|0|NULL|0|0xd489b0|<-->
|0xd48e80|-> |0xd492a0|1|0|NULL|0|0xd48f30|<-->|0xd48e80|2|0|NULL|0|0xd48fe0|<-->|0xd48f30|3|0|NULL|0|0xd49090|<-->|0xd48fe0|4|0|NULL|0|0xd49140|<-->|0xd49090|5|0|NULL|0|0xd491f0|<-->|0xd49140|6|0|NULL|0|0xd492a0|<-->|0xd491f0|7|0|NULL|0|0xd48e80|<-->
|0xd49350|-> |0xd49770|1|0|NULL|0|0xd49400|<-->|0xd49350|2|0|NULL|0|0xd494b0|<-->|0xd49400|3|0|NULL|0|0xd49560|<-->|0xd494b0|4|0|NULL|0|0xd49610|<-->|0xd49560|5|0|NULL|0|0xd496c0|<-->|0xd49610|6|0|NULL|0|0xd49770|<-->|0xd496c0|7|0|NULL|0|0xd49350|<-->
|0xd49820|-> |0xd49c40|1|0|NULL|0|0xd498d0|<-->|0xd49820|2|0|NULL|0|0xd49980|<-->|0xd498d0|3|0|NULL|0|0xd49a30|<-->|0xd49980|4|0|NULL|0|0xd49ae0|<-->|0xd49a30|5|0|NULL|0|0xd49b90|<-->|0xd49ae0|6|0|NULL|0|0xd49c40|<-->|0xd49b90|7|0|NULL|0|0xd49820|<-->
|0xd49cf0|-> |0xd4a110|1|0|NULL|0|0xd49da0|<-->|0xd49cf0|2|0|NULL|0|0xd49e50|<-->|0xd49da0|3|0|NULL|0|0xd49f00|<-->|0xd49e50|4|0|NULL|0|0xd49fb0|<-->|0xd49f00|5|0|NULL|0|0xd4a060|<-->|0xd49fb0|6|0|NULL|0|0xd4a110|<-->|0xd4a060|7|0|NULL|0|0xd49cf0|<-->
|0xd4a1c0|-> |0xd4a5e0|1|0|NULL|0|0xd4a270|<-->|0xd4a1c0|2|0|NULL|0|0xd4a320|<-->|0xd4a270|3|0|NULL|0|0xd4a3d0|<-->|0xd4a320|4|0|NULL|0|0xd4a480|<-->|0xd4a3d0|5|0|NULL|0|0xd4a530|<-->|0xd4a480|6|0|NULL|0|0xd4a5e0|<-->|0xd4a530|7|0|NULL|0|0xd4a1c0|<-->
|0xd4a690|-> |0xd4aab0|1|0|NULL|0|0xd4a740|<-->|0xd4a690|2|0|NULL|0|0xd4a7f0|<-->|0xd4a740|3|0|NULL|0|0xd4a8a0|<-->|0xd4a7f0|4|0|NULL|0|0xd4a950|<-->|0xd4a8a0|5|0|NULL|0|0xd4aa00|<-->|0xd4a950|6|0|NULL|0|0xd4aab0|<-->|0xd4aa00|7|0|NULL|0|0xd4a690|<-->
|0xd4ab60|-> |0xd4af80|1|0|NULL|0|0xd4ac10|<-->|0xd4ab60|2|0|NULL|0|0xd4acc0|<-->|0xd4ac10|3|0|NULL|0|0xd4ad70|<-->|0xd4acc0|4|0|NULL|0|0xd4ae20|<-->|0xd4ad70|5|0|NULL|0|0xd4aed0|<-->|0xd4ae20|6|0|NULL|0|0xd4af80|<-->|0xd4aed0|7|0|NULL|0|0xd4ab60|<-->
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 4
Enter your Choice...: 4
*** under process ****
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 5
*** under process ****
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 6
*** under process ****
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 7
Thank You so much Visit Again....
*************************************************************************************************/
// Name : cinemax.cpp
// Author : NitinShivale
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
class cinemax
{
cinemax *next;
cinemax *prev;
cinemax *rows[10]; //data members
string mname;
long mobno;
int flag;
int seatno;
public:
cinemax() //constructor..to initialize the data memeber and rows array.
{
flag=0;
mobno=0;
seatno=0;
next=prev=NULL;
for(int i=0;i<10;i++)
{
rows[i]=NULL;
}
}
void show();
void showSeat(); //member Functions
void createTheater();
}; //end of class
//This show() function only displays the status of rows i:e Array of pointer.
void cinemax::show()
{
for(int i=0;i<10;i++)
{
cout<<"|"<<rows[i]<<"|-> "<<"\n\n";
}
}
//This showSeat() function displays the memory map of theater after creation of theater...
void cinemax::showSeat()
{
cinemax *temp;
for(int i=0;i<10;i++)
{
cout<<"|"<<rows[i]<<"|-> ";
temp=rows[i];
for(int j=0;j<7;j++)
{
cout<<"|"<<temp->prev<<"|"<<temp->seatno<<"|"<<temp->flag<<"|"<<temp->mname<<"|"<<temp->mobno<<"|"<<temp->next<<"|<-->";
temp=temp->next;
}
cout<<"\n\n";
}
}
//This createTheater() function creates the 10 rows and 7 seats of Theater by using Doubly Circular Linked List.
void cinemax::createTheater()
{
cinemax *p,*temp,*head,*p1;
head=p=p1=temp=NULL;
int i,j;
//code for to create the ten rows....
for(i=0;i<10;i++)
{
p=new cinemax;
p->flag=0;
p->seatno=1;
p->mname="NULL"; //code belongs to first node of each row
p->mobno=0;
p->next=p;
p->prev=p;
rows[i]=p;
temp=p;
head=temp;
//code for to create six seats....
for(j=1;j<7;j++)
{
p1=new cinemax;
p1->flag=0;
p1->seatno=j+1;
p1->mname="NULL"; //assuming that flag zero, mob no zero and movie name i:e mname NULL means seat is not booked yet..initial state of seat.
p1->mobno=0;
p1->next=temp->next;
p1->prev=temp;
temp->next=p1;
head->prev=p1;
temp=p1;
}
}
}
//The program execution starts from main() function.
int main() {
cout << "!!!Welcome To Cinemax Theater!!!" << endl;
cinemax c1; //object c1 creation of cinemax theater to call all the member functions.
int ch;
do
{
cout<<"1.Show Rows Status Before Creation of Theater\n"; //Menu for user to display and operate accordingly..
cout<<"2.Show Rows Status After Creation of Theater\n";
cout<<"3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:\n";
cout<<"4.Show Seat Vacancy in Theater...\n";
cout<<"5.Book My Show..\n";
cout<<"6.Cancel My Show...\n";
cout<<"\nEnter your Choice...: ";
cin>>ch;
switch(ch)
{
case 1:cout<<"\n\nBefore Creation of Theater...\n";
c1.show();
break;
case 2:c1.createTheater(); //member function calling
cout<<"\n\nAfter Theater Creation...\n";
c1.show();
break;
case 3:cout<<"\n After Seat creation of Theater....\n";
c1.showSeat();
break;
case 4:cout<<"/* under process */\n";break;
case 5:cout<<"/* under process */\n";break;
case 6:cout<<"/* under process */\n";break;
}//end of switch case
}while(ch!=7); //end of do while loop.
cout<<"\n\n Thank You so much Visit Again....\n";
return 0;
}//end of main() function
/** ======== OUTPUT OF CINEMAX THEATER =======================
*!!!Welcome To Cinemax Theater!!!
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 1
Before Creation of Theater...
|0|->
|0|->
|0|->
|0|->
|0|->
|0|->
|0|->
|0|->
|0|->
|0|->
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...:2
After Theater Creation...
|0xd48010|->
|0xd484e0|->
|0xd489b0|->
|0xd48e80|->
|0xd49350|->
|0xd49820|->
|0xd49cf0|->
|0xd4a1c0|->
|0xd4a690|->
|0xd4ab60|->
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 3
Enter your Choice...: 3
After Seat creation of Theater....
|0xd48010|-> |0xd48430|1|0|NULL|0|0xd480c0|<-->|0xd48010|2|0|NULL|0|0xd48170|<-->|0xd480c0|3|0|NULL|0|0xd48220|<-->|0xd48170|4|0|NULL|0|0xd482d0|<-->|0xd48220|5|0|NULL|0|0xd48380|<-->|0xd482d0|6|0|NULL|0|0xd48430|<-->|0xd48380|7|0|NULL|0|0xd48010|<-->
|0xd484e0|-> |0xd48900|1|0|NULL|0|0xd48590|<-->|0xd484e0|2|0|NULL|0|0xd48640|<-->|0xd48590|3|0|NULL|0|0xd486f0|<-->|0xd48640|4|0|NULL|0|0xd487a0|<-->|0xd486f0|5|0|NULL|0|0xd48850|<-->|0xd487a0|6|0|NULL|0|0xd48900|<-->|0xd48850|7|0|NULL|0|0xd484e0|<-->
|0xd489b0|-> |0xd48dd0|1|0|NULL|0|0xd48a60|<-->|0xd489b0|2|0|NULL|0|0xd48b10|<-->|0xd48a60|3|0|NULL|0|0xd48bc0|<-->|0xd48b10|4|0|NULL|0|0xd48c70|<-->|0xd48bc0|5|0|NULL|0|0xd48d20|<-->|0xd48c70|6|0|NULL|0|0xd48dd0|<-->|0xd48d20|7|0|NULL|0|0xd489b0|<-->
|0xd48e80|-> |0xd492a0|1|0|NULL|0|0xd48f30|<-->|0xd48e80|2|0|NULL|0|0xd48fe0|<-->|0xd48f30|3|0|NULL|0|0xd49090|<-->|0xd48fe0|4|0|NULL|0|0xd49140|<-->|0xd49090|5|0|NULL|0|0xd491f0|<-->|0xd49140|6|0|NULL|0|0xd492a0|<-->|0xd491f0|7|0|NULL|0|0xd48e80|<-->
|0xd49350|-> |0xd49770|1|0|NULL|0|0xd49400|<-->|0xd49350|2|0|NULL|0|0xd494b0|<-->|0xd49400|3|0|NULL|0|0xd49560|<-->|0xd494b0|4|0|NULL|0|0xd49610|<-->|0xd49560|5|0|NULL|0|0xd496c0|<-->|0xd49610|6|0|NULL|0|0xd49770|<-->|0xd496c0|7|0|NULL|0|0xd49350|<-->
|0xd49820|-> |0xd49c40|1|0|NULL|0|0xd498d0|<-->|0xd49820|2|0|NULL|0|0xd49980|<-->|0xd498d0|3|0|NULL|0|0xd49a30|<-->|0xd49980|4|0|NULL|0|0xd49ae0|<-->|0xd49a30|5|0|NULL|0|0xd49b90|<-->|0xd49ae0|6|0|NULL|0|0xd49c40|<-->|0xd49b90|7|0|NULL|0|0xd49820|<-->
|0xd49cf0|-> |0xd4a110|1|0|NULL|0|0xd49da0|<-->|0xd49cf0|2|0|NULL|0|0xd49e50|<-->|0xd49da0|3|0|NULL|0|0xd49f00|<-->|0xd49e50|4|0|NULL|0|0xd49fb0|<-->|0xd49f00|5|0|NULL|0|0xd4a060|<-->|0xd49fb0|6|0|NULL|0|0xd4a110|<-->|0xd4a060|7|0|NULL|0|0xd49cf0|<-->
|0xd4a1c0|-> |0xd4a5e0|1|0|NULL|0|0xd4a270|<-->|0xd4a1c0|2|0|NULL|0|0xd4a320|<-->|0xd4a270|3|0|NULL|0|0xd4a3d0|<-->|0xd4a320|4|0|NULL|0|0xd4a480|<-->|0xd4a3d0|5|0|NULL|0|0xd4a530|<-->|0xd4a480|6|0|NULL|0|0xd4a5e0|<-->|0xd4a530|7|0|NULL|0|0xd4a1c0|<-->
|0xd4a690|-> |0xd4aab0|1|0|NULL|0|0xd4a740|<-->|0xd4a690|2|0|NULL|0|0xd4a7f0|<-->|0xd4a740|3|0|NULL|0|0xd4a8a0|<-->|0xd4a7f0|4|0|NULL|0|0xd4a950|<-->|0xd4a8a0|5|0|NULL|0|0xd4aa00|<-->|0xd4a950|6|0|NULL|0|0xd4aab0|<-->|0xd4aa00|7|0|NULL|0|0xd4a690|<-->
|0xd4ab60|-> |0xd4af80|1|0|NULL|0|0xd4ac10|<-->|0xd4ab60|2|0|NULL|0|0xd4acc0|<-->|0xd4ac10|3|0|NULL|0|0xd4ad70|<-->|0xd4acc0|4|0|NULL|0|0xd4ae20|<-->|0xd4ad70|5|0|NULL|0|0xd4aed0|<-->|0xd4ae20|6|0|NULL|0|0xd4af80|<-->|0xd4aed0|7|0|NULL|0|0xd4ab60|<-->
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 4
Enter your Choice...: 4
*** under process ****
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 5
*** under process ****
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 6
*** under process ****
1.Show Rows Status Before Creation of Theater
2.Show Rows Status After Creation of Theater
3.Show Memory Map of Seats after Creation of 10 Rows and Seven Seats..:
4.Show Seat Vacancy in Theater...
5.Book My Show..
6.Cancel My Show...
Enter your Choice...: 7
Thank You so much Visit Again....
*************************************************************************************************/
Subscribe to:
Posts (Atom)