
[英]The Hit Object Within the BlockLogic Superclass is Not Being Called
当我按下小写的 L 键时,我想要调用 hit object,每次将方块的长度和宽度减少 5。 似乎 BlockNorm 中的代码没有正确引用 BlockLogic 中的命中 object。 按下 l 时没有效果,但也没有错误。 我尝试放置 print('test'),但没有打印任何内容。 如果我将 ...
[英]The Hit Object Within the BlockLogic Superclass is Not Being Called
当我按下小写的 L 键时,我想要调用 hit object,每次将方块的长度和宽度减少 5。 似乎 BlockNorm 中的代码没有正确引用 BlockLogic 中的命中 object。 按下 l 时没有效果,但也没有错误。 我尝试放置 print('test'),但没有打印任何内容。 如果我将 ...
[英]Inherited value overwriting getter
当我发现这种奇怪的行为时,我正在搞乱课程: class A { test = 1 } class B extends A { get test () { return 2 } } const b = new B() console.log(b.test) output 的逻辑答案应该是2但在运 ...
[英]An Error occured while making a Library Management System using OOPS concept in python- ValueError: too many values to unpack (expected 2)
我正在尝试通过在 python 中使用 OOP 来制作图书馆管理系统。这是我收到错误的代码块: 完整代码: 我试图显示书籍和作者,但出现错误。 我做了什么: 我得到了什么: ...
[英]How to invoke different methods in sub-classes with different parameters by calling a single method in super class object without using if condition?
我有一个Vehicle抽象 class 和两个子类Bike和Car ,它们有 1 个通用方法和 2 个不同的方法。 我想通过在输入 object 上仅调用一个方法来执行主 class 方法中的所有方法。abstract class Vehicle { Tire tire; // ...
[英]Re formating a json
我正在使用它: [ { "questionId":1, "level":1, "difficultyLevel":1.1, "stage":1, "item #":1, "targetWord":"example1", "category":"hard" }, { "questionId":2, ...
[英]Granting private access to two classes without introducing dependency
我有 class,说Rectangle有一个私有方法Rectangle::paint 。 我想让另外两个类访问这个方法,而且只有这两个。 所以,我想到了这个: 问题是,当我想在T中实例化一个Rectangle object 时,这意味着T需要通过包含 header 或使用前向声明来了解Q ,我想避免 ...
[英]Dynamically Initiate a class in another's constructor in Laravel (or php)
为了简单起见,我有两个类:class AddressController extends ApiController { private AddressRepository $addressRepository; public function __construct(Addre ...
[英]Require either one of two methods, or both in abstract class
例如,我有这段代码:export abstract class AbstractButton { // Always have to provide this abstract someRequiredMethod(): void; // One need to prov ...
[英]Factory method by type name
我需要创建采用类型名称和参数的工厂方法。 例子: ShapeFactory.CreateShape("Circle", new Object[] { 4 }) ShapeFactory.CreateShape("Rectangle", new Object[] { 3, 5 }) 从 BaseSha ...
[英]inheritance i laravel :Class name must be a valid object or a string
这是我的父母 class 这是一个具有主要 crud 操作的用户 class 这是我的孩子 class,它是我的用户角色之一,它具有相同的 crud 操作,但它需要更多的功能 当我尝试访问路线时出现此错误:Class 名称必须是有效的 object 或字符串在: ...
[英]What would be the best OOP way to create a function only used inside the class
我想创建一个 function,仅用作同一个 function 中另一个 function 中的 function。我的主要问题是,创建此 function 的最佳 OOP 方法是什么? 我应该 go 至于使用任何类型的装饰器吗? @statimethod 等对于信息,它永远不会在 class 之 ...
[英]Delete an instantiation of a class inside of the class itself once a condition is met
我正在 Arduino 的 16x2 LCD 显示屏上制作无限跑酷游戏。 敌人在屏幕上向左爬行,当他们到达尽头时,我想删除敌人 class 的实例,但我不知道如何删除。 一旦 x position 变为零,我希望它在更新 function 中自行删除。 不管怎样,这是我的代码: class: 这是 ...
[英]I cannot create the super class dont know why
一家建筑公司想要保留在其中工作的员工的记录。 有固定雇员和合同雇员。 合同雇员按小时工作,而永久雇员按月支付工资。 需要为公司开发一个应用程序来存储员工详细信息。 员工员工(int employeeId,String employeeName) 使用传递给构造函数的值适当地初始化 employeeI ...
[英]c# inheritance - how to cast from base type to sub type?
背景我不确定我在标题中的问题是否真的得到了正确表达,但这就是我正在尝试做的。 (我在这里使用了一个虚假的类比来代表团队编写的真实代码。我们不允许发布实际代码。但我试图确保我在我们的代码库中看到的概念已经转移到这个例子中) 我的数据库中有一些车辆记录......其中一些是汽车,另一些是卡车等。我还 ...
[英]Dynamic importing of registered subclasses stored in various modules
请考虑以下派生脚本结构:import abc class BaseMeta(abc.ABCMeta): __registry__ = {} def __init__(cls, name, bases, namespace): if bases: ...
[英]Accessing abstract class properties from extended class
有这个片段:abstract class SuperClass { static String id = 'id'; static String get getId { return id; } } class SubClass extends SuperClass { ...
[英]Should I restrict the constuction of a domain object to an external service?
假设我有值 object LicensePlate。 它是汽车的一部分,汽车是我域中的一个实体。 但是,构建车牌的逻辑不属于我的领域,我只是从领域服务RegistrationAgency.obtainPlate(Car car)获取它,在基础层中实现为DMV.obtainPlate(Car car ...
[英]Java accesing properties with same name in both classes
我有 2 个类,A 和 B,B 继承自 A。这两个类都有一个名为 w 的 int 类型的属性。 在 class 中,A w 是公共的,在 class 中,B w 是私有的。 我使用 B 构造函数创建了 A 类型的 object - A a = new B() 然而,当我尝试访问 B 的属性时,我发现 ...
[英]Achieving singleton pattern in python using only __init__ and not using __new__
我试图在 python 中实现 singleton。为什么下面的代码在 Python 中实现 singleton 模式是错误的? output:<__main__.test object at 0x0000023094388400> Object instantiated <__ ...
[英]How to not overwrite a method from parent class because of a simple change in the code (in Python)
我有这样的事情:def Class1: ... def __getitem__(self, index): ...a lot of code a = query["label_1"].iat[index] ...some m ...