Professional Documents
Culture Documents
Batoul Slaiman 72030543 Final
Batoul Slaiman 72030543 Final
Batoul Slaiman 72030543 Final
import java.util.*;
/**
*
* @author batoul
*/
abstract class device {
@Override
public String toString() {
return "Brand=" +this.getBrand + ", this.getprice=" + price;
}
@Override
public String toString() {
return "laptop{" + super.toString() + “\n+"cpu=" + this,getcpu + ", type=" +
this.gettype + '}';
}
@Override
public boolean isAlternative(Object o) {
if (o instanceof laptop) {
if (((laptop) o).getCpu().equalsIgnoreCase(this.cpu) && ((laptop)
o).getType().equalsIgnoreCase(this.type)) {
return true;
}
}
return false;
}
}
@Override
public String toString() {
return "Usb " + super.toString() + "\nStorage is" + storage + " GB ";
}
@Override
public boolean isAlternative(Object o) {
return true;
}
}
@Override
public String toString() {
String s = "TechShop name=" + name + '\n' + "Devices: \n";
for (int i = 0; i < devices.size(); i++) {
if (devices.get(i) instanceof laptop) {
s += ((laptop) devices.get(i)).toString();
}
if (devices.get(i) instanceof Usb) {
s += ((Usb) devices.get(i)).toString();
}
}
return s;
}
main
public class exammm {