You are on page 1of 39

SHRI DHARMASTHALA MANJUNATHESHWARA

COLLEGE OF ENGINEERING & TECHNOLOGY

INDUSTRY ORIENTED PROGRAMMING PRACTICES PROJECT REPORT


ON
“PLATE DISTRIBUTION SYSTEM”

Submitted by

USN NAME
2SD18CS117 TEJASWINI P A
2SD18CS118 USHA NANDINI V

Under the Guidance of


Prof. Rani Shetty
Dept. of CSE, SDMCET, Dharwad

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


S.D.M. COLLEGE OF ENGINEERING & TECHNOLOGY,
DHARWAD-580002
2021
PLATE DISTRIBUTION SYSTEM

Table of Contents

PROBLEM STATEMENT ......................................................................................1


CHAPTER 1: INTRODUCTION ............................................................................3
CHAPTER 2: DETAILED DESIGN ......................................................................4
CHAPTER 3: PROJECT SPECIFIC REQUIREMENTS .......................................7
CHAPTER 4: IMPLEMENTATION ......................................................................8
CHAPTER 5: RESULTS .......................................................................................29
CHAPTER 6: OUTCOMES…………………………………………………….32
CHAPTER 7: CONCLUSION ..............................................................................38

Page 1 of 38
Plate Distribution

PROBLEM STATEMENT

The proposed system is to develop and design a plate distribution system that
looks into the process of collection of plates that are arranged in a stack by
students who are standing in a queue.

Department of Computer Science and Engineering, SDMCET, Dharwad. 2


Plate Distribution

CHAPTER 1: INTRODUCTION

Every hostel has a mess. In the mess, the plates are arranged one on top of the
other (they are stacked up) and to collect these plates, the students have to stand
in a queue. The students enter the queue (insert), collect the plates and exit the
queue (delete).
By using the combination of stack and queue, a code has been written to
understand this routine easily.
The number of plates present in the stack after students pick the plates up from
the top (pop) and the staff place washed plates on the stack (push) can be easily
predicted. Also, if the number of plates present in the stack are sufficient for the
students standing in the queue, extra plates cannot be added.

Department of Computer Science and Engineering, SDMCET, Dharwad. 3


Plate Distribution
CHAPTER 2: DETAILED DESIGN

Department of Computer Science and Engineering, SDMCET, Dharwad. 4


Plate Distribution

State Diagrams

State Diagram for Stack

State Diagram for Queue

Department of Computer Science and Engineering, SDMCET, Dharwad. 5


Plate Distribution

Class Diagram

Department of Computer Science and Engineering, SDMCET, Dharwad. 6


Plate Distribution

CHAPTER 3: PROJECT SPECIFIC REQUIREMENTS

Hardware Requirements:

i3 Processor
256 MB Ram
512 KB Cache Memory
Hard Disk 10GB

Software Requirements:
Operating System : Windows
Web-Technology : Java

Non-functional Requirements:

• Maintainability
• Portability
• Readability
• Sufficiency and Completeness
• Consistency
• Adaptability

Department of Computer Science and Engineering, SDMCET, Dharwad. 7


Plate Distribution

CHAPTER 4: IMPLEMENTATION

Implementation is the stage where the theoretical design is turned into a working
system.

We have written the code in JAVA Language.


Java was designed to be easy to use and is therefore easy to write, compile,
debug, and learn. It is object oriented and platform-independent. Because of
Java's robustness, ease of use, cross-platform capabilities and security features, it
has become a language of choice for providing worldwide Internet solutions.

Design Specification:

1.void setSize(int size) : sets the size of the stack/queue(setter). It returns


nothing.
2.boolean isFull() : checks whether the stack/queue is Full or not. Return true if
stack/queue is full and false if stack/queue is not full.
3.boolean isEmpty() : checks whether the stack/queue is Empty or not. Return
true if stack/queue is empty and false if stack/queue is not empty.
4.int peek() : returns integer which is at the top of the stack or at the front of the
queue. If queue/stack is empty returns 0.
5.void insert(int x) : Stores integer x at the top of the stack or at the rear end of
the queue, prints the “Successful” message and returns nothing. If the
queue/stack is full it prints appropriate error message.
6.void delete() : removes the top of the stack or an element at the front end of the
queue with “Successful” message and returns nothing. If the queue/stack is empty
it prints the appropriate error message.

Department of Computer Science and Engineering, SDMCET, Dharwad. 8


Plate Distribution

Java Code

Ar package com.sdmect.iopp_project;

public abstract class Array {


abstract void setSize(int size); //function call setSize() and abstract non-access
modifier
abstract boolean isFull(); //function call isFull() and abstract
non-access modifier
abstract boolean isEmpty(); //function call isEmpty() and abstract
non-access modifier
abstract int peek(); //function call peek() and abstract non-access
modifier
abstract void insert(int x); //function call insert() and abstract non-
access modifier
abstract void delete(); //function call delete() and abstract
non-access modifier
}

Stack.java
/*
* to implement stack data structure
*
*/

package com.sdmect.iopp_project;

Department of Computer Science and Engineering, SDMCET, Dharwad. 9


Plate Distribution
/**
* class name: Stack
* functions: isEmpty(),isFull(),peek(),insert(),delete(),peek()
* return-type: boolean,void,int
*
*/

public class Stack extends Array{


private int stk[]; //array name stk of int type and private access
private int top,capacity; //declaring variables of int type private access

/**
* to initialize the size the Stack
* @param size Stack size
*
*/
void setSize(int size) {
stk=new int[size];
top=-1;
capacity=size;
}

/**
* Function that checks whether the stack is full
* return-type boolean
* @return top element

Department of Computer Science and Engineering, SDMCET, Dharwad. 10


Plate Distribution
*/

boolean isFull() {
return top==capacity-1;
}

/**
* Function that checks whether the stack is empty
* return-type boolean
*@return value of top element
*/

boolean isEmpty() {
return top==-1;
}

/**
* Function that returns top element from the stack
* return-type int
* @return 0 if stack is empty else returns top element;value will be always non
negative
*/

int peek() {
if(isEmpty()) {
return 0;

Department of Computer Science and Engineering, SDMCET, Dharwad. 11


Plate Distribution
}
return stk[top];
}

/**
* To insert plate into the stack
* @param x value to be inserted
* return-type void
*/

void insert(int x) {
//if stack is full
if(isFull()) {
System.out.println();

System.out.println("================================================
==========");

System.out.println("================================================
==========");
System.out.println("It's an Overflow,so we can't put back your plate
back.....");

System.out.println("================================================
==========");

System.out.println("================================================
==========");
System.out.println();

Department of Computer Science and Engineering, SDMCET, Dharwad. 12


Plate Distribution
return;
}
//else
stk[++top]=x;
System.out.println("Thank you... You have successfully inserted your
plate");
}

/**
* Function that deletes or provides plate to the student
* return-type void
*/

void delete(){
//if stack is empty
if(isEmpty()) {
System.out.println();

System.out.println("================================================
==========");

System.out.println("================================================
==========");
System.out.println("It's an Underflow, so we don't have any plates
to give you");

System.out.println("================================================
==========");

Department of Computer Science and Engineering, SDMCET, Dharwad. 13


Plate Distribution

System.out.println("================================================
==========");
System.out.println();
return;
}
//else
System.out.println("Here is your plate....");
int y=stk[top--];
}
}

Queue.java
/*
* to implement queue data structure
*/

package com.sdmect.iopp_project;

/*
* class name:Queue
* functions:isFull,isEmpty(),insert(),delete(),peek()
* return-type:boolean,void,int
*/

Department of Computer Science and Engineering, SDMCET, Dharwad. 14


Plate Distribution
public class Queue extends Array{ //class Queue inherits properties of class Array
private int queue[]; //array name queue of int type and private access
private int front,rear; // declaring front, rear of int type and private access
private int capacity,count; //declaring capacity, count of int type and private
access

/**
* to initialize the size the queue
* function name setSize()
* @param size queue size
*
*/

void setSize(int size){


queue= new int[size];
capacity=size;
front=0;
rear=-1;

/**
* Function checks whether the queue is full
* function name isFull()
* return-type boolean
*/

Department of Computer Science and Engineering, SDMCET, Dharwad. 15


Plate Distribution

boolean isFull() {
return count==capacity;
}

/**
* Function checks whether the queue is empty
* function name isEmpty()
* return-type boolean
*/

boolean isEmpty() {
return count==0;
}

/**
* function that allows student to enter into the queue
* function name insert()
* @param x holds student id
* return-type void
*/

void insert(int x) {
//If Queue is full
if(isFull()) {
System.out.println();

Department of Computer Science and Engineering, SDMCET, Dharwad. 16


Plate Distribution

System.out.println("================================================
==========");

System.out.println("================================================
==========");
System.out.println("Sorry the queue is full you can come later....");

System.out.println("================================================
==========");

System.out.println("================================================
==========");
System.out.println();
return;
}
//else
rear=(rear+1)%capacity;
queue[rear]=x;
count++;
System.out.println("You have suuccessfully entered into the queue");
}

/**
* Function that allows to leave the queue
* function name delete()
* return-type void
*/

Department of Computer Science and Engineering, SDMCET, Dharwad. 17


Plate Distribution
void delete() {
//If Queue is empty
if(isEmpty()) {
System.out.println();

System.out.println("================================================
==========");

System.out.println("================================================
==========");
System.out.println("Sorry there is no one in the queue");

System.out.println("================================================
==========");

System.out.println("================================================
==========");
System.out.println();
return;
}
//else
front=(front+1)%capacity;
count--;
System.out.println("You are succesfully out of the queue");
}

/**
* Function that displays front element of the queue
* function name peek()
Department of Computer Science and Engineering, SDMCET, Dharwad. 18
Plate Distribution
* return-type int
* @return front value
*/

int peek() {
if(isEmpty()) {
return 0;
}
return queue[front];
}
}

Main.java
package com.sdmect.iopp_project;

import java.util.Scanner;
/*
* class name:Main
*/

public class Main {


/**
*
* @param args the command line argument
*/

Department of Computer Science and Engineering, SDMCET, Dharwad. 19


Plate Distribution
public static void main(String[] args) { //main function
Array stk1=new Stack(); //created a object of class Array
pointing to class stack
Array queue1=new Queue(); //created a object of class Array
pointing to class Queue
Scanner sc=new Scanner(System.in);

int studentID;

//get input from the user


System.out.println("Good Morning!!!!!!");
System.out.println("----------------------------------------------------------");
System.out.println("Please enter the number of students:");
int n=sc.nextInt();
stk1.setSize(n);
queue1.setSize(n);
System.out.println("----------------------------------------------------------");
for(;;) {
System.out.println("Enter your choice:");
System.out.println("1.Are you a Student");
System.out.println("2.Are you a Staff");
int choice=sc.nextInt();
if(choice==1) {
System.out.println("Enter your choice:");
System.out.println("1.Do you want to enter into the
queue???");
System.out.println("2.Do you want to go out of the
queue???");
Department of Computer Science and Engineering, SDMCET, Dharwad. 20
Plate Distribution
System.out.println("3.EXIT.................");
int selection=sc.nextInt();
System.out.println("-------------------------------------------------------
---");

switch(selection) {
case 1:
System.out.println("Enter Your ID");
studentID=sc.nextInt();
System.out.println("----------------------------------------
------------------");
queue1.insert(studentID); //student enters into
the queue
System.out.println("----------------------------------------
------------------");
break;
case 2:
System.out.println("Enter your ID");
studentID=sc.nextInt();
//queue is full
if(studentID==queue1.peek()) {
System.out.println("--------------------------------
--------------------------");
stk1.delete(); //one plate gets removed
from the Stack
queue1.delete(); //one students goes out
of the Queue
System.out.println("--------------------------------
--------------------------");
Department of Computer Science and Engineering, SDMCET, Dharwad. 21
Plate Distribution
}
//queue is empty
else if(queue1.peek()==0) {
System.out.println("--------------------------------
--------------------------");
System.out.println("There is no one in the
queue...");
System.out.println("--------------------------------
--------------------------");
}
else {
System.out.println("--------------------------------
--------------------------");
System.out.println("Please Wait till your
turn comes.....");
System.out.println("--------------------------------
--------------------------");
}
break;
case 3:
System.out.println("Invalid choice");
System.exit(0);
default:
System.out.println("Invalid choice");
System.exit(0);
}
}
//if you are a staff

Department of Computer Science and Engineering, SDMCET, Dharwad. 22


Plate Distribution
else if(choice==2) {
System.out.println("-------------------------------------------------------
---");
System.out.println("How many plates you want to put
back???");
int totalNoOfPlates=sc.nextInt();
for(int i=1;i<=totalNoOfPlates;i++) {
System.out.println("------------------------------------------------
----------");
stk1.insert(i); //inserts plates into the stack
System.out.println("------------------------------------------------
----------");
}
}
//invalid choice
else {
System.out.println("Invalid Choice");
System.exit(0);
}
}

Department of Computer Science and Engineering, SDMCET, Dharwad. 23


Plate Distribution

Test Cases
StackTest

class StackTest {
void test() {
Stack stk = new Stack();
stk.setSize(3);

Test Case-1: State->Stack Empty


boolean result1 = stk.isEmpty();
stk.delete();
if(result1==true)
{
System.out.println("Test Case 1 is successful, Stack is empty");
}
else
{
System.out.println("Test case 1 is not successful, Stack is not
empty");
}

//Insert the plates into the stack


stk.insert(1);

Test Case-2: State->Stack NENF


if(stk.peek()!=0 && stk.isFull()==false)
{
System.out.println("Test case 2 is successful,stack is NENF");
}
else
{
System.out.println("Test case 2 is unsuccessful,stack is not NENF");
}

Department of Computer Science and Engineering, SDMCET, Dharwad. 24


Plate Distribution
System.out.println();
stk.insert(2);
stk.insert(3);

Test Case-3: State->Stack Full


stk.insert(4);
boolean result2 = stk.isFull();
if(result2==true)
{
System.out.println("Test Case 3 is successful, Stack is full");
}
else
{
System.out.println("Test Case 3 is not successful, Stack is not
full");
}

Test Case-4: State->TopPlate


System.out.println("The top most plate is 3");
if(stk.peek()==3)
{
System.out.println("Test Case 4 is successful ,3 is the top most
plate");
}
else
{
System.out.println("Test Case 4 is not successful ,3 is not the top
most plate");
}
//Remove the plates from stack
stk.delete();
stk.delete();
stk.delete();
}
}
Department of Computer Science and Engineering, SDMCET, Dharwad. 25
Plate Distribution

QueueTest
class QueueTest {
void test() {
Queue que = new Queue();
que.setSize(3);
Test Case-1: State->Queue Empty
que.delete();
boolean result1 = que.isEmpty();
if(result1==true)
{
System.out.println("Test Case 1 is successful,Queue is empty");
}
else
{
System.out.println("Test Case 1 is not successful, Queue is not
empty");
}
//Students entering the queue
que.insert(100);

Test Case-2: State->Queue NENF


if(que.peek()!=0 && que.isFull()==false)
{
System.out.println("Test case 2 is successful, Queue is NENF");
}
else
{
System.out.println("Test case 2 is not successful, Queue is not
NENF");
}
que.insert(101);
que.insert(102);

Test Case-3: State->Queue Full


Department of Computer Science and Engineering, SDMCET, Dharwad. 26
Plate Distribution
que.insert(103);
boolean result2 = que.isFull();
if(result2==true)
{
System.out.println("Test Case 3 is successful, Queue is full");
}
else
{
System.out.println("Test Case 3 is not successful, Queue is not full");
}

Test Case-4: State->FrontMember


System.out.println("First Member in the queue is 100");
if(que.peek()==100)
{
System.out.println("Test Case 4 is successful, Your turn has come");
}
else
{
System.out.println("Test Case 4 is not successful, Wait for your
turn");
}
//Exit the queue
que.delete();
que.delete();
que.delete();
}
}

Department of Computer Science and Engineering, SDMCET, Dharwad. 27


Plate Distribution
Execution of Stack Test Scripts

Execution of Queue Test Scripts

Department of Computer Science and Engineering, SDMCET, Dharwad. 28


Plate Distribution

CHAPTER 5: RESULTS

Student entering the queue:

Staff putting the plate back on the stack:

Department of Computer Science and Engineering, SDMCET, Dharwad. 29


Plate Distribution

When the number of plates the staff is putting back is greater than the number of students:

Student exiting the queue after collecting the plate:

Department of Computer Science and Engineering, SDMCET, Dharwad. 30


Plate Distribution

Student in the middle of the queue trying to exit:

Department of Computer Science and Engineering, SDMCET, Dharwad. 31


Plate Distribution

CHAPTER 6: OUTCOMES

STUDENT OUTCOMES:

• We learnt how to develop test cases and write a program to test reusable
objects.
• We learnt how to incorporate a lot of features we had studied in our code
and also learnt how to apply them in a business scenario.
• We got to practice Pair programming – an agile software development
technique. We learnt how to work in a team and coordinate with each other.

PROJECT OUTCOMES:

Through this project we were able to implement the following features:

Naming convention and consistency – The written code follows the naming
convention. The name of the package, classes, methods are given according to
their function. The code is uniform and consistent and hence is more reliable.

Package naming convention(lower case) -


Domain_name.company_name.project_name.program
Class naming convention : Camel casing
In our project we have used this convention as
com.sdmcet.iopp_project – package name
Array.java, Stack.java, Queue.java, Main.java-Class names

Department of Computer Science and Engineering, SDMCET, Dharwad. 32


Plate Distribution
Readable and Effective – The written code is readable and its intention can
clearly be communicated to the reader. This is because of the following factors
included in the code:

• Usage of whitespace to separate disparate areas of code.


• Usage meaningful variables and method/function/class names.
• Effective documentation.
Sample Code:
private int stk[]; //array name stk of int type and private access
private int top,capacity; //declaring variables of int type private access

/**
* To insert plate into the stack
* @param x value to be inserted
* return-type void
*/

void insert(int x) {
//if stack is full
if(isFull()) {
System.out.println();

System.out.println("=======================================
===================");

System.out.println("=======================================
===================");
System.out.println("It's an Overflow,so we can't put back your
plate back.....");

System.out.println("=======================================
===================");

System.out.println("=======================================
===================");
System.out.println();
return;
}
Department of Computer Science and Engineering, SDMCET, Dharwad. 33
Plate Distribution
//else
stk[++top]=x;
System.out.println("Thank you... You have successfully inserted your
plate");
}

Portability – The written code is portable as it is written in Java. The output of


the Java compiler is bytecode, which leads to the security and portability of the
Java code.

Sample Code:
package com.sdmect.iopp_project;

public abstract class Array {//beginning of the class Array


abstract void setSize(int size); //function call setSize() and
// abstract non-access modifier
abstract boolean isFull(); //function call isFull()
// and abstract non-access
// modifier
abstract boolean isEmpty(); //function call isEmpty() and
// abstract non-access modifier
abstract int peek(); //function call peek() and abstract
// non-access modifier
abstract void insert(int x); //function call insert() and
// abstract non-access modifier
abstract void delete(); //function call delete() and abstract
// non-access modifier
}//end of the class Array

Maintainability – The program written can easily be modified to correct faults,


improve performance or adapt to a changed environment.

Sample Code:
//If we want to add any methods in any class, modifications need not //to be done
in other classes
package com.sdmect.iopp_project;
Department of Computer Science and Engineering, SDMCET, Dharwad. 34
Plate Distribution

/**
* class name: Stack
* functions: isEmpty(),isFull(),peek(),insert(),delete(),peek()
* return-type: boolean,void,int
*
*/

public class Stack extends Array{ //beginning of the class Stack


private int stk[]; //array name stk of int type and
// private access
private int top,capacity; //declaring variables of int type
// private access

/**
* to get the size the Stack
* @return int
* return the size of the stack
*/
void getSize() {
return size;
}
}//end of the class Stack

Testability - The code has been designed and implemented to make it easier for
tests to achieve complete and repeatable code path coverage and simulates all
usage situations in a cost-efficient manner.

Sample Code:
Test Case-3: State->Stack Full
stk.insert(4);
boolean result2 = stk.isFull();
if(result2==true)
{
System.out.println("Test Case 3 is successful, Stack is full");
}
Department of Computer Science and Engineering, SDMCET, Dharwad. 35
Plate Distribution
else
{
System.out.println("Test Case 3 is not successful, Stack is not
full");
}

Adaptability – The code is adaptable and can be changed according to the


changing technology and need.

//If we need any change we can do it in particular classes according to the need
package com.sdmect.iopp_project;

/**
* class name: Queue
* functions: isEmpty(),isFull(),peek(),insert(),delete(),peek()
* return-type: boolean,void,int
*
*/

public class Queue extends Array{ //beginning of the class Queue


private int que[]; //array name que of int type and
// private access
private int top,capacity; //declaring variables of int type
// private access

/**
* to get the size the Queue
* @return int
* return the size of the queue
*/
void getSize() {
return size;
}
}//end of the class Queue

Department of Computer Science and Engineering, SDMCET, Dharwad. 36


Plate Distribution
Cohesiveness and coupling – The written code has low coupling
(interdependency between the modules is low) and high cohesion (functional
relatability of the modules is high).

Coupling: There is no interdependency between classes such as Stack and Queue,


so the written code has zero coupling.

Cohesiveness: There is no direct relationship between functions.


But in main class we are calling methods that are depending on other methods.

Sample Code:
System.out.println("Enter your ID");
studentID=sc.nextInt();
//queue is full
if(studentID==queue1.peek()) { //beginning of if
System.out.println("----------------------------------------------------------");
//Functional dependency
stk1.delete(); //one plate gets removed from the Stack
queue1.delete(); //one students goes out of the Queue
System.out.println("----------------------------------------------------------");
}//end of if

Sufficiency – The written code is sufficient as the component captures those


characteristics that are necessary to permit a meaningful and efficient interaction
with the component.

Completeness – The written code is complete as it has all the necessary and
appropriate parts and meets all the requirement of the project.

Department of Computer Science and Engineering, SDMCET, Dharwad. 37


Plate Distribution

CHAPTER 6: CONCLUSION

This program has been designed in such a way that, it makes the plate
distribution process in hostel messes more organized, systematic and less chaotic.
The program has been written by taking most of the possible cases into
consideration. We have also incorporated all the important features in the
program.

Department of Computer Science and Engineering, SDMCET, Dharwad. 38

You might also like