interface

How to extend class?

安稳与你 提交于 2019-12-13 05:36:07
问题 I'm making a change to an API that serves data. Some of the searches require data about an author and take a IAuthor object. The API has an IAuthor interface and a single concrete class that implements IAuthor called Author . I need to add a boolean property, IsNovelist that will change the semantics of some but not all searches. I've heard about the open/closed principle and it would seem that changing the IAuthor and/or Author classes would violate this. How then to make this simple change?

C++ lnk error 2019 unresolved external symbol virtual errors because of an interface…(?)

限于喜欢 提交于 2019-12-13 05:30:24
问题 Im having problems with making a good interface and use it... My setup overview: An "interface" GraphicsLibrary.H ... virtual void drawPoint(const Point& p, unsigned char r, unsigned char g, unsigned char b, double pointSize); with an "empty" GraphicsLibrary.ccp! because its an interface, so "OpenGL" is an graphics library... so i have an OpenGL.CPP with: void GraphicsLibrary::drawPoint(const Point& p, unsigned char r, unsigned char g, unsigned char b, double pointSize) { //some code } which

POO and Interface (in C#)

邮差的信 提交于 2019-12-13 04:51:31
问题 I need to understand Interface : I have this structure : Core (contain Interface) BLL (Contain object who implement interface DAL (Contain Data access) IHM (Call BLL object) For example, i have an Interface Core.IVehicle who describe a basic vehicle like : Color Speed And a one method : LoadVehicle(int id) //return a iVehicule with speed and color In my BLL, I have an object "BLL.Car" who implement "Core.IVehicle". So, i will have a LoadVehicle method and access to DALfor get basics

Ideas to enforce strict (better) type safety with a Java Interface as the parameter

核能气质少年 提交于 2019-12-13 04:48:03
问题 Update based on inputs below. Now and again I feel efforts for type-safe use of Java interfaces less than straightforward. Here's a simple example of what we'd like to do: a design, following. When it comes to implementation after several attempts to get type safety, I'm ( again ) discovering that we need to think in Java to encourage Java to support our needs. I'm made improvements on the original example. I'm leaving the question open because there's probably a better way to go about things

Java: If-else instanceof extended classes

痞子三分冷 提交于 2019-12-13 04:46:56
问题 I have an abstract class X and some classes who extend this class, call them A , B and C . In some other class Y I have a few methodcalls that depend on the type of the class. The if-else statement looks like this: public class Y implements InterfaceY { public Y(){ } public String doStuff (X x, Boolean flag) { String s = ""; if (x instanceof A) { doStuff((A) x)); } else if (x instanceof B) { doStuff((B) x)); } else if (x instanceof C) { doStuff((C) x, flag); } else { throw new Exeption(); }

How to trigger fragment methods through parent activity button onclick listener

那年仲夏 提交于 2019-12-13 04:00:21
问题 I'm pretty sure I have tried everything. I have a tabbed activity utilizing 6 fragments within a viewpager. Part of the layout includes a FINISH button within the parent activity, that once clicked should call 6 methods, one in each fragment, from 1-6. For the life of me nothing seems to be able to work. What I have tried: 1) Creating a button onclicklistener for the finish button within each fragment and calling the methods. It only calls the method in the first fragment and does not seem to

Is it possible to json-serialize a class with explicitly implemented interface properties?

旧街凉风 提交于 2019-12-13 03:20:42
问题 interface A { string Name {get;set;}} interface B { string Name {get;set;}} class C : A, B { string A.Name {get;set;} string B.Name {get;set;}} var c = new C(); ((A)c).Name = "a"; ((B)c).Name = "b"; var s = JsonConvert.SerializeObject(c); The result is an empty json object with no property values. Is it possible to serialize and deserialize such an object? 回答1: Tell json to serialize private properties: class C : A, B { [JsonProperty] string A.Name { get; set; } [JsonProperty] string B.Name {

set value of interface in testing a method

守給你的承諾、 提交于 2019-12-13 03:08:20
问题 so I'm currently creating a unit test for a class that I've implemented a few weeks ago. I'll show you first the particular part of the class where I'm working on. public void PostEvent(eVtCompId inSenderComponentId, eVtEvtId inEventId, long inEventReference, IF_SerializableData inEventData) { if(mEventMap.ContainsKey(inEventId)) { mEventMap[inEventId](inSenderComponentId, inEventReference, inEventData); } } For this method, I have 4 parameters. 1st, an enum; 2nd, another enum; 3rd, long; 4th

How to fix: Anylogic does not connect to Eclipse over Socket

妖精的绣舞 提交于 2019-12-13 02:54:25
问题 I'm trying to create a scenario on my Macbook with Mojave in Anylogic, which is part of agent-based simulation with many different tools. My idea is to connect Anylogic via Java Interface to Eclipse. The main problem is, that Anylogic somehow does not respond. I have tried many different codes with sockets, but could not find one, which worked for Anylogic. I'm using the free version of Anylogic and created a Java Interface under my Main Project. To run the Java Interface I press right-click

Database Structure to store multiple inheritance classes

拜拜、爱过 提交于 2019-12-13 02:43:59
问题 I have two distinct (no inheritance) interfaces: IInvestable and IPricable and two classes: IndexClass and FundClass that are stored in seperate tables in my DB. IndexClass is IPriceable FundClass is IPriceable and IInvestable . I need a table to store prices against an IndexClass and a FundClass I need a table to store that FundClasses are invested in. One way might be to have two tables: Pricable and Investable which just have an ID column. Then have a foreign key on IndexClass : PricableID