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

📄 computer.java

📁 复数运算
💻 JAVA
字号:
package myPackage;
import java.io.*;
  public class  Computer{ 
          //定义属性:品牌,颜色,CPU,内存,硬盘,价格,状态   
     private String brand; 
     private String color;
     private String CPU;
     private String RAM;
     private String HDisk;
     private float  price; 
     private boolean  state1=true ;  //true为打开状态 
     private boolean  state2=true ;  //true为挂起状态
     public  Computer( ){                   //定义缺省值的构造方法
       brand="HEDY";
       color="white";
       CPU="AMD";
       RAM="KingMax";
       HDisk="WD";	
       price=3999;
      }
    
     public Computer(String brand,String color,String CPU,String RAM,String HDisk,float price){
       this.brand=brand;            //定义具有指定值的构造方法
       this.color=color;
       this.CPU=CPU;
       this.RAM=RAM;
       this.HDisk=HDisk;	
       this.price=price ;
       }         
       
     public void display() {       //输出品牌,颜色,CPU,内存,硬盘,价格
       System. out .println("品牌: "+brand);
       System. out .println("颜色: "+color);
       System. out .println("CPU : "+CPU);
       System. out .println("内存: "+RAM);
       System. out .println("硬盘: "+HDisk);
       System. out .println("价格: "+price+"元");       
       } 
                        
     public void ComStateOn( ){     //控制计算机的打开与关闭
       if(state1) {   
              state1=false;
       	      System.out.println("The computer is shutdowned!!!");
       	  }      	    
       else {
       	   state1=true;
       	   System.out.println("The computer is starting!!!");      	         	    
          }
       }
       	
      public void ComStateWaken( ){  //控制计算机的挂起与恢复          
       	  if( state2){
       	      state2=false;
       	      System.out.println("The computer is sleeping!!!");
       	   }
          else {
       	      state2=true;
       	      System.out.println("The computer is awake!!!");      	   
           }		       	
        }
    }
   

	 	

⌨️ 快捷键说明

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