0
메신저는 자바 스크립트로 팩토리를 만들려고 시도하지만, 페이지 업로드시에는 을 상속하고 재생할 수 없습니다. 상속받은 클래스는 4 개였습니다. 하나의 슈퍼 clas,하지만 언제든지 나는 저녁 클래스에 기본값을 삽입 메신저하지만, 정의되지 않은 오류 obj를주는 코드를로드하려고 -Pc- 어떻게해야합니까?공장에서 상속을하려고하면 어떤 에러가 발생합니다.
function Pc(obj) {
this.type = obj.type || "enter Type";
this.company = obj.company || "enter Company";
this.warrenty = obj.warrenty || "enter Warranty";
this.model = obj.model || "enter model";
this.link = obj.link || "http://" + obj.link || "input link";
this.price = obj.price || "Enter Price";
this.picture = obj.picture || "input Pic";
this.number = obj.number || "input number";
}
function HardDrive(obj) {
this.rotationalSpeed = obj.rotationalSpeed || "7200RPM";
this.buffersize = obj.buffersize || "64MB";
this.capacity = obj.capacity || "1TB";
this.Interface = obj.Interface || "'SATA 6 Gb/s";
}
HardDrive.prototype = new Pc();
function Proccesor(obj) {
this.core = obj.core || 4;
this.cache = obj.cache || "4MB";
this.speed = obj.speed;
this.inTheCart = false;
}
Proccesor.prototype = new Pc();
function Memory(obj) {
this.speed = obj.speed || "DDR3 1600";
this.intrface = obj.intrface || "8GB";
this.casLatency = obj.casLatency || '9';
this.capacity = obj.Capacity || "8GB";
this.inTheCart = false;
}
Memory.prototype = new Pc();
function MotherBoard(obj) {
this.socket = obj.socket || "1115";
this.connection = obj.connection || "Alot";
}
Memory.prototype = new Pc();
function ComputerFactory() {
this.newPart = function(obj) {
switch (obj.type.toLowerCase()) {
case "hardrive":
this.pcPart = HardDrive;
break;
case "proccesor":
this.pcPart = Proccesor;
break;
case "memory":
this.pcPart = Memory;
break;
case "motherboard":
this.pcPart = MotherBoard;
break;
}
return new this.pcPart(obj);
}
}
var x = new ComputerFactory();
var hd1 = ComputerFactory.newPart({
type: "hardrive",
model: 'WD5000AAKX',
buffersize: '16 MB',
capacity: '500GB',
link: "www.google.co.il",
picture: 'WD500Gb.jpg',
price: 230,
number: 'hd1',
});
감사하지만 작동하지 않지만 이전에 사용해 보았습니다. – Ilan