📄 compstore.java
字号:
}
if (compchoice==3){
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!");
}
if(choicems==1){
if (ms1.getUsed() == true) {
System.out.println("Mouse is set\n");
}
ms1.setUsed(true);
ms2.setUsed(false);
ms3.setUsed(false);
}
else if(choicems==2){
if (ms2.getUsed() == true) {
System.out.println("Mouse is set\n");
}
ms1.setUsed(false);
ms2.setUsed(true);
ms3.setUsed(false);
}
else if(choicems==3){
if (ms3.getUsed() == true) {
System.out.println("Mouse is set\n");
}
ms1.setUsed(false);
ms2.setUsed(false);
ms3.setUsed(true);
}
}
else if (submenuchoice==4){
for(int m=0; m <kbArray.length; m++){
if(!kbArray[m].getUsed()){
System.out.println((m+1)+"." +"Keyboard: \t" +kbArray[m].getDescription()+" "+ msArray[m].getPrice());
System.out.println();
}
}
System.out.print("\nPlease enter your choice-->:\t");
try {
s= br.readLine ();
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!");
}
if(choicekb==1){
if (kb1.getUsed() == true) {
System.out.println("Keyboard is set\n");
}
kb1.setUsed(true);
kb2.setUsed(false);
kb3.setUsed(false);
}
else if(choicekb==2){
if (kb2.getUsed() == true) {
System.out.println("Keyboard is set\n");
}
kb1.setUsed(false);
kb2.setUsed(true);
kb3.setUsed(false);
}
else if(choicekb==3){
if (kb3.getUsed() == true) {
System.out.println("Keyboard is set\n");
}
kb1.setUsed(false);
kb2.setUsed(false);
kb3.setUsed(true);
}
}
else if (submenuchoice==5){
System.out.println("CONFIGURATION:\n--------------");
System.out.println("Processor:\t" + sbArray[choicesb-1].getDescription());
System.out.println("Monitor:\t " + mnArray[choicemn-1].getDescription());
System.out.println("Mouse:\t" +msArray[choicems-1].getDescription());
System.out.println("Keyboard:\t" + kbArray[choicekb-1].getDescription());
double totalprice = sbArray[choicesb-1].getPrice() +mnArray[choicemn-1].getPrice() +msArray[choicems-1].getPrice()+ kbArray[choicekb-1].getPrice();
System.out.println("Total price: - $"+ totalprice);
}
}
}
}
if (mainmenuchoice==3){
System.out.println("************Select one of three systems (1,2 or 3) **********************\n");
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){
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==2){
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("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);
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -