import java.util.*; |
public class Main{ |
public static void main(String[] args) { |
Scanner scan = new Scanner(System.in); |
String model = scan.next(); |
double fre = scan.nextDouble(); |
int cores = scan.nextInt(); |
CPU cpu1 = new CPU(model, fre, cores); |
|
model = scan.next(); |
Mainboard mb1 = new Mainboard(model); |
|
model = scan.next(); |
int size = scan.nextInt(); |
Memory me1 = new Memory(model, size); |
|
model = scan.next(); |
size = scan.nextInt(); |
Screen sc1 = new Screen(model, size); |
|
model = scan.next(); |
String cap = scan.next(); |
Harddisk h1 = new Harddisk(model, cap); |
|
Computer com1 = new Computer(cpu1, mb1, me1, sc1, h1); |
|
|
model = scan.next(); |
fre = scan.nextDouble(); |
cores = scan.nextInt(); |
CPU cpu2 = new CPU(model, fre, cores); |
|
model = scan.next(); |
Mainboard mb2 = new Mainboard(model); |
|
model = scan.next(); |
size = scan.nextInt(); |
Memory me2 = new Memory(model, size); |
|
model = scan.next(); |
size = scan.nextInt(); |
Screen sc2 = new Screen(model, size); |
|
model = scan.next(); |
cap = scan.next(); |
Harddisk h2 = new Harddisk(model, cap); |
|
Computer com2 = new Computer(cpu2, mb2, me2, sc2, h2); |
System.out.println(com1.equals(com2)); |
System.out.println( "Computer1:\n" +com1.toString()); |
System.out.println( "Computer2:\n" +com2.toString()); |
|
|
scan.close(); |
} |
} |
class Computer{ |
CPU cpu; |
Mainboard mb; |
Memory me; |
Screen sc; |
Harddisk h; |
public Computer(CPU c, Mainboard _mb, Memory _me, Screen _sc, Harddisk _h) { |
cpu = c; |
mb = _mb; |
me = _me; |
sc = _sc; |
h = _h; |
} |
public boolean equals(Computer com) { |
if ( cpu.equals(com.cpu) && mb.equals(com.mb) && me.equals(com.me) && sc.equals(com.sc) && h.equals(com.h) ) |
return true ; |
else |
return false ; |
} |
public String toString() { |
return cpu.toString()+mb.toString()+me.toString()+sc.toString()+h.toString(); |
} |
} |
class CPU{ |
String model; |
double frequency; |
int cores; |
public CPU(String m, double f, int c) { |
model = m; |
frequency = f; |
cores = c; |
} |
public boolean equals(CPU cpu){ |
if ( this .model.equals(cpu.model)&&( this .frequency == cpu.frequency)&&( this .cores==cpu.cores)) { |
return true ; |
} |
else |
return false ; |
} |
public String toString() { |
return "CPU:\n" + "Model: " +model + "\n" + "Frequency: " +String.format( "%.1f" ,frequency) + "\n" + "Number of Cores: " +cores + "\n" ; |
} |
} |
class Mainboard{ |
String model; |
public Mainboard(String m) { |
model = m; |
} |
public boolean equals(Mainboard mb) { |
if ( this .model.equals(mb.model)) |
return true ; |
else |
return false ; |
} |
public String toString() { |
return "Mainboard:\n" + "Model: " +model + "\n" ; |
} |
} |
class Memory{ |
String model; |
int size; |
public Memory(String m, int s) { |
model = m; |
size = s; |
} |
public boolean equals(Memory me) { |
if ( this .model.equals(me.model) && ( this .size==me.size)) |
return true ; |
else |
return false ; |
} |
public String toString() { |
return "Memory:\n" + "Model: " +model + "\n" + "Size: " +size + "\n" ; |
} |
} |
class Screen{ |
String model; |
int size; |
public Screen(String m, int s) { |
model = m; |
size = s; |
} |
public boolean equals(Screen sc) { |
if ( this .model.equals(sc.model) && ( this .size==sc.size)) |
return true ; |
else |
return false ; |
} |
public String toString() { |
return "Screen:\nModel: " +model + "\n" + "Size: " +size + "\n" ; |
} |
} |
class Harddisk{ |
String model; |
String size; |
public Harddisk(String m, String s) { |
model = m; |
size = s; |
} |
public boolean equals(Harddisk h) { |
if ( this .model.equals(h.model) && this .size.equals(h.size)) |
return true ; |
else |
return false ; |
} |
public String toString() { |
return "Harddisk:\nModel: " +model + "\n" + "Size: " +size; |
} |
} |