用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

142-计算机类

2018-10-13 作者: 芙蓉妹妹举报

[java]代码库

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);    
 
        String cm = scan.next();
        double f = scan.nextDouble();
        int c = scan.nextInt();
        String mainm = scan.next();
        String mem = scan.next();
        int ms = scan.nextInt();
        String sm = scan.next();
        int ss = scan.nextInt();
        String hm = scan.next();
        int hs = scan.nextInt();
        Computer c1 = new Computer(cm,f,c,mainm,mem,ms,sm,ss,hm,hs);
        cm = scan.next();
        f = scan.nextDouble();
        c = scan.nextInt();
        mainm = scan.next();
        mem = scan.next();
        ms = scan.nextInt();
        sm = scan.next();
        ss = scan.nextInt();
        hm = scan.next();
        hs = scan.nextInt();
        Computer c2 = new Computer(cm,f,c,mainm,mem,ms,sm,ss,hm,hs);
        System.out.println(c1.equals(c2));
        System.out.println("Computer1:");
        System.out.println(c1.toString());
        System.out.println("Computer2:");
        System.out.println(c2.toString());
        scan.close();
   }
}
class Computer
{  

       String CPUmodel;
       double Frequency;
       int Cores;
       String Mainboardmodel;
       String Memorymodel;
       int Memorysize;
       String Screenmodel;
       int Screensize;
       String Harddiskmodel;
       int Harddisksize;
       public Computer(String cm, double f, int c, String mainm, String mem, int ms, String sm, int ss, String hm, int hs)
       {
    	   CPUmodel = cm;
    	   Frequency = f;
    	   Cores = c;
    	   Mainboardmodel = mainm;
    	   Memorymodel = mem;
    	   Memorysize = ms;
    	   Screenmodel = sm;
    	   Screensize = ss;
    	   Harddiskmodel = hm;
    	   Harddisksize = hs;
       }
       String getCPUmodel()
       {
    	   return CPUmodel;
       }
       double getFrequency()
       {
    	   return Frequency;
       }
       int getCores()
       {
    	   return Cores;
       }
       String getMainboardmodel()
       {
    	   return Mainboardmodel;
       }
       String getMemorymodel()
       {
    	   return Memorymodel;
       }
       int getMemorysize()
       {
    	   return Memorysize;
       }
       String getScreenmodel()
       {
    	   return Screenmodel;
       }
       int getScreensize()
       {
    	   return Screensize;
       }
       String getHarddiskmodel()
       {
    	   return Harddiskmodel;
       }
       int getHarddisksize()
       {
    	   return Harddisksize;
       }
       boolean equals(Computer c)
       {
    	   if(!CPUmodel.equals(c.getCPUmodel()))
    		   return false;
    	   else if( !(Frequency == c.getFrequency() ) ) 
    		   return false;
    	   else if( !(Cores == c.getCores() ) ) 
    		   return false;
    	   else if(!Mainboardmodel.equals(c.getMainboardmodel()))
    		   return false;
    	   else if(!Memorymodel.equals(c.getMemorymodel()))
    		   return false;
    	   else if( !(Memorysize == c.getMemorysize() ) ) 
    		   return false;
    	   else if(!Screenmodel.equals(c.getScreenmodel()))
    		   return false;
    	   else if( !(Screensize == c.getScreensize() ) ) 
    		   return false;
    	   else if(!Harddiskmodel.equals(c.getHarddiskmodel()))
    		   return false;
    	   else if( !(Harddisksize == c.getHarddisksize() ) ) 
    		   return false;
    	   else 
    		   return true;
       }
       public String toString()
       {
    	   return "CPU:\nModel: "+CPUmodel+"\nFrequency: "+String.format("%.1f",Frequency)+"\nNumber of Cores: "+Cores+"\nMainboard:\nModel: "+Mainboardmodel+"\nMemory:\nModel: "+Memorymodel+"\nSize: "+Memorysize+"\nScreen:\nModel: "+Screenmodel+"\nSize: "+Screensize+"\nHarddisk:\nModel: "+Harddiskmodel+"\nSize: "+Harddisksize;
       }
}


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...