⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compstore.java

📁 The assessment of JAVA in the Western Insititute Technology.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
		        }
		        catch ( IOException ioe ) {
		                  System.out.println(ioe.toString());
		        }
		        
		        
		     catch(ArrayIndexOutOfBoundsException aoe){
		        
		         	System.out.println("Please enter a right number !");
	 		  }
	 		  
	 		  catch(NumberFormatException nfe){
	 		  	
	 		     System.out.println("Please enter a right number from menu!");
	 		  }

	
        System.out.println("CONFIGURATION:\n--------------");
	 	
	 	comps[compchoice-1].setSysBlock(sbArray[choicesb-1]);
	 	sbArray[choicesb-1].setUsed(true);
	 	comps[compchoice-1].setMonitor(mnArray[choicemn-1]);
	 	mnArray[choicemn-1].setUsed(true);
	 	comps[compchoice-1].setMouse(msArray[choicems-1]);
	 	msArray[choicems-1].setUsed(true);
	 	comps[compchoice-1].setKeyboard(kbArray[choicekb-1]);
        kbArray[choicekb-1].setUsed(true);
        
        
	 	System.out.println("Processor:\t"+comps[compchoice-1].getSysBlock().getDescription());
	 	System.out.println("Monitor: \t"+comps[compchoice-1].getMonitor().getDescription());
	 	System.out.println("Mouse: \t"+comps[compchoice-1].getMouse().getDescription());
	 	System.out.println("Keyboard: \t"+comps[compchoice-1].getKeyboard().getDescription());
	 	 	
	double totalprice = comps[compchoice-1].getSysBlock().getPrice() +comps[compchoice-1].getMonitor().getPrice() +comps[compchoice-1].getMouse().getPrice()+  comps[compchoice-1].getKeyboard().getPrice();
    		
	 	System.out.println("\ntotal price:--"+totalprice);	
	 	
	 	
	 	}	
	 		
	 		
	 	if(compchoice==3){	
	 	
	 	 System.out.println("\n##--Select SystemBlock--##"); 
			
			  System.out.println("--components availble:--\n");

	 
        for (int i = 0; i < sbArray.length; i++) {
       	
       	if(!sbArray[i].getUsed()){
       	
          System.out.println((i + 1) + ". " + "Processor:   " + sbArray[i].getDescription()+"      "  + sbArray[i].getPrice());
          System.out.println(); 
   
    }
         }
         
         System.out.print("\nPlease enter your choice-->  :\t");
         
         
         		
		 try {
		            s = br.readLine (); //read input string
		            choicesb = Integer.parseInt(s);
//		            comps[compchoice -1].setSysBlock(sbArray[choicesb-1]);
//		            sbArray[choicesb-1].setUsed(true);
		          
		        }
		        catch ( IOException ioe ) {
		                  System.out.println(ioe.toString());
		        }
		        	// check what the input is
		        	  catch(ArrayIndexOutOfBoundsException aoe){
	 		  	System.out.println("Please enter a right number !");
	 		  }
	 		  
	 		  catch(NumberFormatException nfe){
	 		  	
	 		     System.out.println("Please enter a right number from menu!");
	 		  }	
	 		  
	 		  
//	  if (choicesb == 1) {
//        if (sb1.getUsed() == true) {
//          System.out.println("SystemBlock is set\n");
//    
//      
//        }
//        sb1.setUsed(true);
//        sb2.setUsed(false);
//        sb3.setUsed(false);
//       
//       
//		}
//	 	else if(choicesb==2){
//	 		if (sb2.getUsed() == true) {
//          System.out.println("SystemBlock is set\n");
//          
//        }
//        sb1.setUsed(false);
//        sb2.setUsed(true);
//        sb3.setUsed(false);
//       
//	 	}	
//	 	else if(choicesb==3){
//	 	 if (sb3.getUsed() == true) {
//          System.out.println("SystemBlock is set\n");
//          
//        }
//        sb1.setUsed(false);
//        sb2.setUsed(false);
//        sb3.setUsed(true);
//     
//	    }  
	    
	    
	    
	    	System.out.println("##--Select System Monitor--##");
	 			    System.out.println("--components availble:--\n");

      for (int i = 0; i < mnArray.length; i++) {
      	
      	
      		if(!mnArray[i].getUsed()){
     
        System.out.println((i + 1) + ". " + "Monitor:   " + mnArray[i].getDescription()+"    "  + mnArray[i].getPrice());
        System.out.println(); 
        
       }
       
      }
      
      System.out.print("\nPlease enter your choice-->  :\t");
      
          try {
		                s = br.readLine (); //read input string
		                 choicemn = Integer.parseInt(s);
		        }
		        catch ( IOException ioe ) {
		                  System.out.println(ioe.toString());
		        }
		        
		        
		      catch(ArrayIndexOutOfBoundsException aoe){
		         	System.out.println("Please enter a right number !");
	 		  }
	 		  
	 		  catch(NumberFormatException nfe){
	 		  	
	 		     System.out.println("Please enter a right number from menu!");
	 		  }

	        
	 
	 		
	 	 System.out.println("##--Select System Mouse--##");
         System.out.println("--components availble:--\n");	
	 		
	 		
            for (int i = 0; i < msArray.length; i++) {
    	
    		if(!msArray[i].getUsed()){
     
       System.out.println((i + 1) + ". " + "Mouse:   " + msArray[i].getDescription()+"      "  + msArray[i].getPrice());
        System.out.println(); 
        
       }
       
      }
      
      System.out.print("\nPlease enter your choice-->  :\t");

      try {
		                s = br.readLine (); //read input string
		                 choicems = Integer.parseInt(s);
		        }
		        catch ( IOException ioe ) {
		                  System.out.println(ioe.toString());
		                  
		        }
		        
		        
		     catch(ArrayIndexOutOfBoundsException aoe){
		        
                   	System.out.println("Please enter a right number !");
	 		  }
	 		  
	 		  catch(NumberFormatException nfe){
	 		  	
	 		     System.out.println("Please enter a right number from menu!");
	 		  }

	             
		        	// check what the input is	  
	 	
	 		System.out.println("##--Select System Keyboard--##");
	 		System.out.println("--components availble:--\n");
	 		
	 	 for (int z = 0; z < kbArray.length; z++) {
           	
           if(!kbArray[z].getUsed()){
     
                System.out.println((z + 1) + ". " + "Keyboard:   " + kbArray[z].getDescription()+"      "  + kbArray[z].getPrice());
                System.out.println();    
       
              }  
       }
        		   
	         System.out.print("\nPlease enter your choice-->  :\t");
	         
	         
	         	try {
		                s = br.readLine (); //read input string
		                 choicekb= Integer.parseInt(s);
		        }
		        catch ( IOException ioe ) {
		                  System.out.println(ioe.toString());
		        }
		        
		        
		     catch(ArrayIndexOutOfBoundsException aoe){
		        
		         	System.out.println("Please enter a right number !");
	 		  }
	 		  
	 		  catch(NumberFormatException nfe){
	 		  	
	 		     System.out.println("Please enter a right number from menu!");
	 		  }

	
        System.out.println("CONFIGURATION:\n--------------");
	 	
	 	comps[compchoice-1].setSysBlock(sbArray[choicesb-1]);
	 	sbArray[choicesb-1].setUsed(true);
	 	comps[compchoice-1].setMonitor(mnArray[choicemn-1]);
	 	mnArray[choicemn-1].setUsed(true);
	 	comps[compchoice-1].setMouse(msArray[choicems-1]);
	 	msArray[choicems-1].setUsed(true);
	 	comps[compchoice-1].setKeyboard(kbArray[choicekb-1]);
        kbArray[choicekb-1].setUsed(true);
        
        
	 	System.out.println("Processor:\t"+comps[compchoice-1].getSysBlock().getDescription());
	 	System.out.println("Monitor: \t"+comps[compchoice-1].getMonitor().getDescription());
	 	System.out.println("Mouse: \t"+comps[compchoice-1].getMouse().getDescription());
	 	System.out.println("Keyboard: \t"+comps[compchoice-1].getKeyboard().getDescription());
	 	 	
	double totalprice = comps[compchoice-1].getSysBlock().getPrice() +comps[compchoice-1].getMonitor().getPrice() +comps[compchoice-1].getMouse().getPrice()+  comps[compchoice-1].getKeyboard().getPrice();
    		
	 	System.out.println("\ntotal price:--"+totalprice);
	 	
		}   
		}
	 	
	
	 if (mainmenuchoice==2){
	 			System.out.println("\n****** Select one of three computer(1,2 or3) *******");
	 			System.out.print("Please enter your choice-->  :\t");
	 			
	 			
	 			try {  
	 			s= br.readLine ();//read input string
	 			compchoice = Integer.parseInt(s);
	 		}
	 	    catch ( IOException ioe ){
	 	    	System.out.println(ioe.toString());
	 	    }
	 	    
	 	    
	 	    	catch(ArrayIndexOutOfBoundsException aoe){
	 	    
	 	    	 	     	System.out.println("Please enter a right number !");
	 		  }
	 		  
	 		  catch(NumberFormatException nfe){
	 		  	
	 		     System.out.println("Please enter a right number from menu!");
	 		  }
	 		  
	 	if(compchoice==1){	  
	 		  	 		     
	 	 while(!(submenuchoice == 6)){
	 		     	System.out.println("\n********Assembling*********\n");
	 		     	System.out.println("1.Set SystemBlock");
	 		     	System.out.println("2.Set Monitor");
	 		     	System.out.println("3.Set Mouse");
	 		     	System.out.println("4.Set Keyboard");
	 		     	System.out.println("5.Get Confirguration");
	 		     	System.out.println("6.Return to Main Menu");
	 		     	System.out.print("Please enter your choice-->:\t");
	 		
	 		
	 			try {
	 			s= br.readLine ();
	 			submenuchoice = Integer.parseInt(s);
	 		}
	 	    catch ( IOException ioe ){
	 	    	System.out.println(ioe.toString());
	 	    	
	 	    	}
	 	    		// check what the input is
	 	    		    
	 			 if (submenuchoice==1){
	 			 	
	 			 	
	 			 	for(int i=0; i <sbArray.length; i++){
	 			 		
	 			 		if(!sbArray[i].getUsed()){
	 			 			
	 			 			
	 			 			System.out.println((i+1)+"." +"Processor:     \t" +sbArray[i].getDescription()+"        "+ sbArray[i].getPrice());
	 			 			System.out.println();
	 			 			
	 			 	     
	 			 	 }
	 		}
	 			
	 			    
	 			
	 			  	 
	 			
	 			
	 			
	 			
	 			 	 	  
	 		    System.out.print("\nPlease enter your choice-->:\t");
	 			 	    
	 			         try {
	 			         s= br.readLine ();
	 			         choicesb = Integer.parseInt(s);
	 		             }
	 	                 catch ( IOException ioe ){
	 	     	         System.out.println(ioe.toString());
	 	    	         }
	 	    	         
	 	    	         
	 	    catch(ArrayIndexOutOfBoundsException aoe){
	 	    	         
	 	    	          	System.out.println("Please enter a right number !");
	 		  }
	 		  
	 		  catch(NumberFormatException nfe){
	 		  	
	 		     System.out.println("Please enter a right number from menu!");
	 		  }

	 	    	         
	 	    	         
	 	 	         
	 	     if(choicesb==1){  
                if (sb1.getUsed() == true) {
                  System.out.println("SystemBlock is set\n");
         
                   }
                 sb1.setUsed(true);
                  sb2.setUsed(false);
                  sb3.setUsed(false);
       
		          }    
	 	         else if(choicesb==2){
	 	           	if (sb2.getUsed() == true) {
                  System.out.println("SystemBlock is set\n");
          
                   }
                 sb1.setUsed(false);
                  sb2.setUsed(true);
                 sb3.setUsed(false);
       
	 	         }	
	 	         else if(choicesb==3){
	 	         if (sb3.getUsed() == true) {
                  System.out.println("SystemBlock is set\n");
          
                    }
                 sb1.setUsed(false);
                 sb2.setUsed(false);
                 sb3.setUsed(true);
                
	 	 	    
	 	
	 	}
	 	
	 }
	 		
	 	
	 	
	 	else if (submenuchoice==2){
	 			
	 			
	 			for(int l=0; l <mnArray.length; l++){
	 			 		
	 			 		if(!mnArray[l].getUsed()){
	 			 			
	 			 			
	 			 			System.out.println((l+1)+"." +"Monitor:     \t" +mnArray[l].getDescription()+"        "+ mnArray[l].getPrice());
	 			 			System.out.println();
	 			 			
	 			 	     
	 			 	 }
	 		}
	 			 	
	 			
	 			   System.out.print("\nPlease enter your choice-->:\t");
	 			 	    
	 			         try {
	 			         s= br.readLine ();
	 			         choicemn = Integer.parseInt(s);
	 		             }
	 	                 catch ( IOException ioe ){
	 	     	         System.out.println(ioe.toString());
	 	    	         }
	 	    	         
	 	    	          	
	 	    	          	
	 	   catch(ArrayIndexOutOfBoundsException aoe){ 	
	 	    	          	
	 	    	          	System.out.println("Please enter a right number !");
	 		  }
	 		  
	 		  catch(NumberFormatException nfe){
	 		  	
	 		     System.out.println("Please enter a right number from menu!");
	 		  }

	 	    	         
	 	    
	 	    
	 	    	 if(choicemn==1){
	 		 if (mn1.getUsed() == true) {
         System.out.println("System Monitor is set\n");
          
        }
            mn1.setUsed(true);
            mn2.setUsed(false);
            mn3.setUsed(false);
	 			
	 		}
	 		
	 		else if(choicemn==2){
	 				
	 	if (mn2.getUsed() == true) {
         System.out.println("System Monitor is set\n");
          
        }
            mn1.setUsed(false);
            mn2.setUsed(true);
            mn3.setUsed(false);
		   
	 		}
	 		else if(choicemn==3){
	 	if (mn3.getUsed() == true) {
         System.out.println("System Monitor is set\n");
          
        }
            mn1.setUsed(false);
            mn2.setUsed(false);
            mn3.setUsed(true);
	 	    
	 	    
	
	 			
	 			
	 			
	 		}
	 			} 	 	  
	 		  
	 		else if (submenuchoice==3){
	 			
	 			
	 		
	 			for(int n=0; n <msArray.length; n++){
	 			 		
	 			 		if(!msArray[n].getUsed()){
	 			 			
	 			 			
	 			 			System.out.println((n+1)+"." +"Mouse:     \t" +msArray[n].getDescription()+"        "+ msArray[n].getPrice());
	 			 			System.out.println();
	 			 			
	 			 	     
	 			 	 }
	 		}
	 				 
	 			 	 	  
	 		    System.out.print("\nPlease enter your choice-->:\t");
	 			 	    
	 			         try {
	 			         s= br.readLine ();
	 			         choicems = Integer.parseInt(s);
	 		             }
	 	                 catch ( IOException ioe ){
	 	     	         System.out.println(ioe.toString());
	 	    	         }
	 	    	         
	 	    catch(ArrayIndexOutOfBoundsException aoe){       
	 	    	         
	 	    	          	System.out.println("Please enter a right number !");
	 		  }
	 		  
	 		  catch(NumberFormatException nfe){
	 		  	
	 		     System.out.println("Please enter a right number from menu!");
	 		  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -