Skip to content

Commit

Permalink
Update Tempproj.java
Browse files Browse the repository at this point in the history
  • Loading branch information
vggudi authored Jun 10, 2018
1 parent 6a86066 commit 1c6e865
Showing 1 changed file with 175 additions and 2 deletions.
177 changes: 175 additions & 2 deletions src/tempproj/Tempproj.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,110 @@ void displayInfo(){

}
}
class BasicMaterials{

int materialID;
String[] size={"LOW","MEDIUM","HIGH"};
int quantity[]=new int[3];
int emplCount;
Scanner inp=new Scanner(System.in);


void addProduct(int mid,int s){
materialID=mid;
//size[s]=s;
System.out.println("Enter the no.of MATERIALS : ");
int data=0;
do{
data=inp.nextInt();
if(data<=0)
System.out.println("Quantity need to be more than 0");
}
while(data<=0);
quantity[s]+=data;

}

void removeProduct(int mid,int s){
int data=0;
int flag=0;
do{
System.out.println("Enter the no.of materials to be removed: ");
data=inp.nextInt();
if(data<=0)
System.out.println("Quantity need to be more than 0");
else if(data>quantity[s]){
System.out.println("Insufficient no. of materials in the warehouse");
displayInfo();
System.out.println("Willing to unload less no. of materials");
System.out.println("Press\n 1:YES \n 0:NO");
boolean choice=true;
int value=inp.nextInt();
if(quantity[s]==0 && value==1){
System.out.println("There are no materials in the storage location");
break;
}
if(value==0){
choice=false;
flag=1;
}
if(!choice)
break;
}
}
while(data<0 || data>quantity[s]);
if(quantity[s]!=0 && flag==0)
quantity[s]-=data;
}

void allotEmployee(){
int eval;
int extra;
int i;
for(i=0;i<=2;i++){
eval=quantity[i]/100;
extra=quantity[i]%100;
switch(i){
case 0:eval=eval*4;
if(extra!=0 && extra<50)
extra=2;
else if(extra>=50)
extra=4;
break;
case 1:eval=eval*3;
if(extra!=0 && extra<50)
extra=2;
else if(extra>=50)
extra=3;
break;
case 2:eval=eval*2;
if(extra!=0 && extra<50)
extra=1;
else if(extra>=50)
extra=2;
break;
}
System.out.println("Eval="+eval);
System.out.println("Extra="+extra);
emplCount+=eval+extra;

}
}


void displayInfo(){
System.out.println("Material ID is: "+materialID);
System.out.println("Material Details are:");
System.out.println("CLASS\t QUANTITY\t");
System.out.println("------------------------");
for(int i=0;i<=2;i++){
System.out.println(size[i]+"\t"+quantity[i]);
}
allotEmployee();
System.out.println("Employees count is: "+emplCount );

}
}

public class Tempproj {

Expand All @@ -127,9 +230,79 @@ public static void main(String[] args) {

switch(choice){
case 1:
//TODO Basic material code is to be fixed!!


BasicMaterials bm[]=new BasicMaterials[10];
for(int i=0;i<bm.length;i++){
bm[i]=new BasicMaterials();
}

for(;;){
System.out.println("\nYou are dealing with Storage area of Basic Materials!!!");
System.out.println("Permitted material IDs are 100-109");
System.out.println("Available choices to deal with particular material are \n"
+ " 1.Add/update any material\n"
+ " 2.Remove the material\n"
+ " 3.Employee Count \n"
+ " 4.Display material details\n"
+ " 5.Go back to main menu\n"
+ "Choose your option :");
choice=inp.nextInt();
int matID,pos;
int size;

switch(choice){
case 1:
matID=acceptPID();
System.out.println("Size Menu Includes: \n 1.Low\n 2.Medium\n 3.High\n"
+ "Choose the size of the product to be added(0,1,2 only permitted) :");
size=inp.nextInt();
pos=matID%100;

for(int i=0;i<bm.length;i++){
if(i==pos){
bm[i].addProduct(matID, size);
bm[i].allotEmployee();
break;
}
}
break;
case 2:
matID=acceptPID();
System.out.println("Size Menu Includes: \n 1.Large\n 2.Medium\n 3.Small\n"
+ "Choose the size of the product to be removed(0-2) :");
size=inp.nextInt();
pos=matID%100;

for(int i=0;i<bm.length;i++){
if(i==pos){
bm[i].removeProduct(matID, size);
bm[i].allotEmployee();
break;
}
}
break;
case 3:
int ecount=0;
for(int i=0;i<bm.length;i++){
ecount+=bm[i].emplCount;
}
System.out.println("Total number of employees in the warehouse=" +ecount);
break;
case 4:
matID=acceptPID();
pos=matID%100;
bm[pos].displayInfo();
break;

}
if(choice==5)
break;

}
break;


break;

case 2:
//TODO Fabricated parts code is to be fixed!!
Expand Down

0 comments on commit 1c6e865

Please sign in to comment.