The book says:
The decorator pattern can be used to extend (decorate) the
functionality of a certain object
I have a rabbit animal. And I want my rabbit to have, for example, reptile skin. Just want to decorate a common rabbit with reptile skin.
I have the code. First I have abstract class Animal with everythig that is common to any…
I am getting this error on code that used to work. I have not changed the code.
Here is the full error:
The CLR has been unable to transition from COM context 0x3322d98 to COM context 0x3322f08 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long…
I would like to work out a number's factorial. My factorial rule is in a Prolog file and I am connecting it to a C++ code. Can someone tell me what is wrong with my C++ interface please?
% factorial.pl
factorial( 1, 1 ):-
!.
factorial( X, Fac ):-
X > 1,
Y is X - 1,
factorial( Y, New_Fac ),
Fac is X * New_Fac.
//…
Does anyone know why including a term such as:
t = PL_new_term_ref();
would cause an Unhandled Exception error message:
0xC0000005: Access violation reading location 0x0000000c.
(Visual Studio 2008)
I have a header file:
class UserTaskProlog : public ArAction
{
public:
UserTaskProlog( const char* name = " sth " );
…
I am creating a graphics program that draws 100 x 100 squares next to each other depending on the user-specified grid size. The user also inputs 4 colours for the squares to be coloured (e.g. if they enter red,green,blue,yellow the squares will be coloured in that order, repeating the colours).
Is it possible to loop the colours from the…
Ran accross the following code in an article and didn't think it was standard C/C++ syntax for the char* array. As a test, both Visual C++ (visual studio 2005) and C++ Builder Rad XE both reject the 2nd line.
Without using #defines, anyone have any tricks/tips for keeping enums and a string array sort of in sync without resorting to STL…
My problem is rather complex to explain, so I'll show you an example:
http://ewolf.bplaced.de/misc/float.htm
I want to have a floated element (the blue box) to be be placed over two other elements (red and green) and I want the whole thing to be fixed-width and centered (done by the box with the black border) while the background of the…
After looking at how to count the occurrences of distinct values in a field, I am wondering how to count the occurrences of each distinct value if the distinct values are known (or enumerated).
For example, if I have a simple table -
TrafficLight Colour
------------ ------
1 Red
2 …
I'm curious whether many of us who do design or take design decisions have ever heard of this problem.
I'm aware there are dangerous color combinations, like green + red. This is probably one of the most popular cases of color blindness. If you have green text on a red background and vice versa some people won't see anything.
I've…
How to pass by-name repeated parameters in Scala?
The following code fails to work:
scala> def foo(s: (=> String)*) = {
<console>:1: error: no by-name parameter type allowed here
def foo(s: (=> String)*) = {
^
Is there any other way I could pass a variable number of by name parameters to…
I've been playing with a DataBus-type design for a hobby project, and I ran into an issue. Back-end components need to notify the UI that something has happened. My implementation of the bus delivers the messages synchronously with respect to the sender. In other words, when you call Send(), the method blocks until all the handlers…
I'm manually building an SQL query where I'm using an Array in the params hash for an SQL IN statement, like: ("WHERE my_field IN('blue','green','red')"). So I need to take the contents of the array and output them into a string where each element is single quoted and comma seperated (and with no ending comma).
So if the array…
i was wondering if there is a data structure optimized to count frequencies against data that is stored in a database table-like format. for example, the data comes in a (comma) delimited format below.
col1, col2, col3
x, a, green
x, b, blue
...
y, c, green
now i simply want to count the frequency of col1=x or col1=x and…
Hi,
Sorry, I'm quite new to Java.
I've stumbled across HttpGet and HttpPost which seem to be perfect for my needs, but a little long winded. I have written a rather bad wrapper class, but does anyone know of where to get a better one?
Ideally, I'd be able to do
String response = fetchContent("http://url/", postdata);
…
I'm using minitest in Rails to do testing, but I'm running into a problem that I hope a more seasoned tester can help me out with because I've tried looking everywhere for the answer, but it doesn't seem that anyone has run into this problem or if they have, they opted for an integration test.
Let's say I have a…
Hi,
I completely revamped an app. Tested it for a while on my device and emulator. The app worked fine. However when I updated the app through the Android market, my users experienced crashes.
Since there is no way to properly debug this procedure I asume the crash is caused by old data which is not being…
I have a main instance named 'myinstance' which has the element . Color can be 'Red', 'Blue', 'Green' or ''Yellow'. The colors are populated in a drop-down from another instance called 'colorsinstance'. When my form loads, I want the default in the dropdown to be set to 'Green' in the nodeset binding.
…
Should I dispose GDI+ object before its creation?
Is recommended to always Dispose GDI+ object after using it.
by e.g.
Pen p = new Pen(Color.Green);
// use 'p'
p.Dispose();
now, if I have this situation:
Pen p = new Pen(Color.Green);
// use green 'p'
p = new Pen(Color.Red); // Should I Dispose…
Hi,
I am working on C#.DotNet windows application project, here i am using Infragistics control. In this project i want to add image over text control. This image contains two portion, 35% of image have white color another 65% of image have green color.In this image 2nd portion(green color) i…
Based on the following example URL structure:
mysite.com/mypage.aspx?a=red&b=green&c=blue
Pages in the application use ASP.net user controls and some of these controls build a query string. To prevent duplicate keys being created e.g. &pid=12&pid=10, I am researching methods…
Background: I am mapping Sybase stored procedure return values to java objects using Spring.
For example I map a Sybase datatype of varchar as a String type in Java, and a Sybase datatype of int as an int type in Java, etc.
I have come across the following code in one of the stored…
I have two parent classes in a huge project, let's say ClassA and ClassB. Each class has many subclasses, which in turn have many subclasses, which in turn have many subclasses, etc.
My task is to "marry" these two "families" so that both inherit from a SINGLE parent. I need to…