我试图从我的2个类中创建2个对象,一个Person对象和一个Drink对象,然后我想调用我的饮用方法传递一个Drink对象,但我不知道怎么做,我怎么办那?这是我的代码,我不知道它为什么不起作用
function Drink(full, alcoholic){
this.alcoholic = alcoholic;
this.full = full;
}
function Person(name, age) {
this.name = name;
this.age = age;
this.drinking = function drinking(Drink) {
if (age >= 18) {
this.Drink.full = false;
} else {
console.log("you cannot drink because of your age")
this.Drink.full=true;
};
}
}
John = new Person("John",24);
Sam = new Person("Sam",2);
x = new Drink(true,true);
console.log(x)
console.log(John.drinking(x))
console.log(Sam.drinking(x))
答案 0 :(得分:1)
在this.Drink上删除它
xliff = XDocument.Load(Path.GetFullPath(FilePath));
XNamespace xmlns = "urn:oasis:names:tc:xliff:document:1.2";
XNamespace ns = "http://sdl.com/FileTypes/SdlXliff/1.0";
string testid = xliff.Descendants()
.Elements(xmlns + "trans-unit")
.Elements(xmlns + "seg-source")
.Elements(xmlns + "mrk")
.Where(e => e.Attribute("mtype").Value == "seg" && e.Attribute("mid").Value == SegId)
.FirstOrDefault().Parent.Parent.PreviousNode.ToString();