callParent(arguments)
时间: 2023-05-18 10:07:27 浏览: 134
这是一个在 JavaScript 中调用父类构造函数的方法。它可以用来继承父类的属性和方法。具体实现方式可以参考以下代码:
function Child() {
Parent.call(this, arguments);
}
其中 Parent 是父类的构造函数,Child 是子类的构造函数。通过使用 call 方法,我们可以在子类中调用父类的构造函数,并将子类的 this 对象作为参数传递进去。这样就可以实现子类继承父类的属性和方法了。
相关问题
TypeError: arguments did not match any overloaded call: QStandardItemModel(parent: typing.Optional[QObject] = None): argument 1 has unexpected type 'int' QStandardItemModel(rows: int, columns: int, parent: typing.Optional[QObject] = None): not enough arguments
这个错误是因为你在创建 QStandardItemModel 时,传递的参数类型与该函数所接受的参数类型不匹配。根据错误提示,QStandardItemModel 可以接受两种不同类型的参数:
1. 不传递参数,即使用默认参数。此时 QStandardItemModel 会以 None 作为 parent 参数创建一个空模型。
2. 传递 rows 和 columns 参数来指定模型的行数和列数,可以同时传递 parent 参数。
你的错误提示显示,你传递了一个 int 类型的参数,这个参数并不是 QStandardItemModel 所接受的任何一种参数类型。请确保你传递的参数类型与 QStandardItemModel 所需的参数类型匹配。
use java to continue the question,Add a class Lender that extends User. The constructor of the Lender class takes as arguments a name and the number of books lent by the user. The Lender class does not have any instance variable. Warning: the constructor of the Lender class takes as argument the number of books lent by the lender, but the book instance variable of the User class indicates how many books the user borrowed! Lending books is the same as borrowing a negative number of books. The moreBook method of the Lender class increases the number of books lent by the lender user by the number given as argument to the method (so the books borrowed by the lender becomes more negative!) Make sure you test all the methods of your new Lender class using testLender method. Here are some tests for your new Lender class: public static void testLender() { Lender l = new Lender("Anna",5); System.out.println(l.getName() == "Anna"); System.out.println(l.getBook() == -5); l.setBook(-6); System.out.println(l.getBook() == -6); l.moreBook(2); System.out.println(l.getBook() == -8); l.moreBook(-9); System.out.println(l.getBook() == 1); } Also, do not forget to modify your Test class to test the Lender class.
Alright, here's the updated code with the Lender class:
```
public class User {
private String name;
private int book;
public User(String name) {
this.name = name;
this.book = 0;
}
public String getName() {
return name;
}
public int getBook() {
return book;
}
public void setBook(int book) {
this.book = book;
}
public void borrowBook(int num) {
book += num;
}
}
public class Lender extends User {
public Lender(String name, int numBooksLent) {
super(name);
borrowBook(-numBooksLent);
}
public void moreBook(int num) {
borrowBook(-num);
}
}
public class Test {
public static void main(String[] args) {
User u = new User("Bob");
System.out.println(u.getName() == "Bob");
System.out.println(u.getBook() == 0);
u.borrowBook(3);
System.out.println(u.getBook() == 3);
u.setBook(5);
System.out.println(u.getBook() == 5);
Lender l = new Lender("Anna", 5);
System.out.println(l.getName() == "Anna");
System.out.println(l.getBook() == -5);
l.setBook(-6);
System.out.println(l.getBook() == -6);
l.moreBook(2);
System.out.println(l.getBook() == -8);
l.moreBook(-9);
System.out.println(l.getBook() == 1);
}
}
```
In the Lender class constructor, we call the parent constructor with the `name` argument, and then immediately call `borrowBook(-numBooksLent)` to lend out the specified number of books.
The `moreBook` method simply calls `borrowBook` with a negative value to lend out more books.
In the `Test` class, we now have tests for both the `User` and `Lender` classes.
阅读全文
相关推荐





Traceback (most recent call last): File "d:\pythonbaijiahao\baijiahao.py", line 82, in mianrun sub_element.click() File "D:\python3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 81, in click self._execute(Command.CLICK_ELEMENT) File "D:\python3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 710, in _execute return self._parent.execute(command, params) File "D:\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 425, in execute self.error_handler.check_response(response) File "D:\python3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element 管理商品 is not clickable at point (930, 347). Other element would receive the click: <svg viewBox="64 64 896 896" focusable="false" data-icon="vertical-align-top" width="1em" height="1em" fill="currentColor" aria-hidden="true">...</svg> (Session info: MicrosoftEdge=113.0.1774.42) Stacktrace:








