abstract

Java - Force implementation of an implemented method

橙三吉。 提交于 2019-12-10 15:44:42
问题 I have three classes which I have a problem with. They are named: GameScene, StageScene, StageOne. My problem is that I want to implement initialize in StageScene, but still force StageOne to implement it, so that whenever someone uses a StageOne object (stageOne.initialize()), initialize would be run for both StageScene and StageOne. Anyone know how this could be done? public abstract class GameScene { public abstract void initialize(); } public abstract class StageScene extends GameScene {

overriding abstract generic method from non generic class

瘦欲@ 提交于 2019-12-10 13:28:44
问题 base class class Drawer { public abstract void Draw<T>(T type); } derived class #1 class ADrawer : Drawer { public override void Draw<T>(List<T> list) { foreach (var a in list) { DrawA(a); } } public void DrawA(Agent a) { //draw code here } } derived class #2 class AnotherDrawer : Drawer { public override void Draw<T>(T number) { if (number == 1) { //draw code } } } The error is in the #1 derived class : "no suitable method found to override" Should I be using 'virtual' in the base class as

Problem with Covariant return types from an abstract method

与世无争的帅哥 提交于 2019-12-10 11:19:26
问题 I’m trying to wrap up a two day beat down on Abstract methods and return type Covariance, I’ve already posted two similar questions and I am eternally grateful to the community for the info provided, I just need one last push to get to the finish line. Here is what I am trying to do: 2 abstract classes, RecruiterBase and CandidateBase, both have concreate implementations of RecruiterA and CandidateA. RecruiterBase has an abstract method to get all recruited candidates returning IQueryable. My

abstract type in scala

时光总嘲笑我的痴心妄想 提交于 2019-12-10 09:34:55
问题 I am just going through abstract type in Scala and I got an error The example I was trying: scala> class Food abstract class Animal { type SuitableFood <: Food def eat(food: SuitableFood) } defined class Food defined class Animal scala> class Grass extends Food class Cow extends Animal { type SuitableFood = Grass override def eat(food: Grass) {} } defined class Grass defined class Cow scala> class Fish extends Food defined class Fish scala> val bessy: Animal = new Cow bessy: Animal = Cow

C++ - “Member function not declared” in derived class

一笑奈何 提交于 2019-12-10 04:17:01
问题 I have a problem in MSVC++ 2008 where VS2008 is throwing this compile error: error C2509: 'render' : member function not declared in 'PlayerSpriteKasua' Now, what's confusing me is that render() is defined, but in an inherited class. The class definition works like this: SpriteBase -Inherited By-> PlayerSpriteBase -Inherited By-> PlayerSpriteKasua So, a pared-down version of SpriteBase.h is the following: class SpriteBase { public: //Variables=============================================

Semantics of abstract traits in Scala

℡╲_俬逩灬. 提交于 2019-12-10 01:28:42
问题 I am wondering what the semantics of using the abstract keyword in combination with a trait is. If the trait does not define any abstract methods, the abstract keyword does not prevent me from creating an instance: scala> abstract trait T defined trait T scala> new T{} res0: java.lang.Object with T = $anon$1@12cd927d On the other hand, if the trait does define an abstract method, I cannot create an instance (without implementing this method of course) no matter if the abstract keyword is

Get the parameter prefix in ADO.NET

别来无恙 提交于 2019-12-09 12:53:58
问题 I want to generate several SQL statements based on a column list using the column names as parameters. Edit : C# var columns = new string[] { "COL1", "COL2" }; var tableName = "TABLE_1"; var prefix = "@"; // TODO get this from the provider factory string sqlInsert = string.Format( "INSERT INTO {0}\n( {1}) VALUES\n({2})", tableName, string.Join(", ", columns), string.Join(", ", columns.Select(c => prefix + c))); Generated SQL: INSERT INTO TABLE_1 ( COL1, COL2) VALUES (@COL1, @COL2) This works

Correct design for entity classes. Need recommendations

霸气de小男生 提交于 2019-12-09 03:41:39
问题 For example, I have entity class User : public class User { private long id; private String name; // setters and getters } Next, I add new entity class: Comment public class Comment { private long id; private String comment; // setters and getters } Next, I can add more and more entity classes. And, at this moment I think: I can/must bind/connect in logical structure my entity classes or no? What I mean? I try explain: Point 1: All this classes: User , Comment and more other - POJO . Idea 1:

Rhino mock an abstract class w/o mocking its virtual method?

半腔热情 提交于 2019-12-09 03:13:34
问题 Can I execute the body of a virtual method that lives on an abstract class which has been mocked using Rhino Mocks? To be clear, I'm not trying to mock the behavior of the virtual method. I'm trying to /test/ the virtual method (on the mocked class). Is this idea a blatant misuse of Rhino Mocks? 回答1: Yes, that should be absolutely fine. I can't say I've tried it, but I'd be very surprised if it failed. EDIT: I suspect you want the PartialMock method. Here's an example: using System; using

interface vs abstract class [duplicate]

ぃ、小莉子 提交于 2019-12-08 09:50:48
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Interface or abstract class? I have a group of classes defined as follows: namespace VGADevices.UsingAbstractClass { public abstract class VGA { public abstract int HorizontalResolution { get; set; } public abstract int VerticalResolution { get; set; } } public class LCDScreen : VGA { public override int HorizontalResolution { get; set; } public override int VerticalResolution { get; set; } } } // namespace