I am trying to write a life simulation in python with a variety of animals. It is impossible to name each instance of the classes I am going to use because I have no way of knowing how many there will be.
So, my question:
How can I automatically give a name to an object?
I was thinking of creating a "Herd" class which could be all the...
My problem is thus: I need a way to ensure only one given class can instantiate another. I don't want to have to make the other a nested inner class or something dumb like that. How do I do this? I forget offhand.
...
hello
I want all the Method-ClassName from namespace
like i have system.windows.Forms
wehen in visual studio we rigt system.windows.Forms. it will suggest box of all the related method,class,enum extra
i need to fetch the same ,how can i do that in C#
Thanks
...
When WSDL importer wizard generates the interfaces, all properties have the Index option, but reading the code and the InvokeRegistry unit, I can't found what is that for, anyone know if it is really necessary?
Like this
Login = class(TRemotable)
private
[...]
published
property User: string Index (IS_OPTN) read GetUser ...
I have a type which I consider use it as struct.
It represents single value
It is immutable
But the problem is, it has 6 fields of int.
So which solution I should use for this type?
keep using struct?
change to class?
or pack 6 integers into an array of int, so it has only one field
EDIT
Size of struct with 6 integer fields is ...
I just finished reading this article on the advantages and disadvantages of exceptions and I agree with the sentiment that Try-Catch blocks should not be used for "normal" control-flow management (don't use them like a goto). However, one author made (good) points about Maintainability and especially Performance that made me wonder abou...
Hi
I am modeling a class diagram. An attribute of a class is an enumeration. How do i model this? Normally you do something like this: - name : string But how to do this with an enum?
Thnx in advance :)
...
I need help in designing my PHP classes where I need to extend from multiple classes.
I have a general class, Pagination.php that does all sort of pagination and sorting. All other classes will use this for pagination.
To make my life easier, I made a class generator that generates a class from MySQL table. All the properties, getters,...
I have code similar to this in my application:
class A
{
public: int b;
}
class C
{
public: int d;
}
void DoThings (void *arg1, MYSTERYTYPE arg2);
A obj_a;
C obj_c;
DoThings(&obj_a, &A::b);
DoThings(&obj_c, &C::d);
The question is - What should MYSTERYTYPE be? neither void* nor int work, despite the value &A::b being printed j...
I am using Kohana and just found this piece of code in their autoloading method
// Class extension to be evaluated
$extension = 'class '.$class.' extends '.$class.'_Core { }';
// Start class analysis
$core = new ReflectionClass($class.'_Core');
if ($core->isAbstract())
{
// Make the extension abstract
$extension = 'a...
I'm faced with a design decision that doesn't smell to me, but gives me pause. Take a look at the following code sample:
public interface IGenerator
{
///<summary>
/// Combines two generators; performs magic as well
/// </summary>
BaseGenerator Combine(BaseGenerator next);
///<summary>
/// Does what a generator does.
///...
I have the following situation I think would be best to show in sample program code. I have a Java class that extends JPanel. In this class are two objects which are two more JPanels. In one of the JPanel objects is a JTable object. I added a listener to this JTable that detects a double click. When it detects a double click, I want...
For domain entities, should property names be prefaced with the entity name? I.E. my class Warehouse has a property WarehouseNumber. Should that property be named WarehouseNumber or simply Number?
Thoughts?
...
Is there any advantage over using a class over a struct in cases such as these?
(note: it will only hold variables, there will never be functions)
class Foo {
private:
struct Pos { int x, y, z };
public:
Pos Position;
};
Versus:
struct Foo {
struct Pos { int x, y, z } Pos;
};
Similar questions:
http://stackov...
For my current project I want to be able to load some classes from a dll (which is not always the same, and may not even exist when my app is compiled). There may also be several alternative dll's for a given class (eg an implementation for Direct3D9 and one for OpenGL), but only one of the dlls will be loaded/used at any one time.
I ha...
I'm trying to pass an instance of a class between two separate classes, like the following.
//classes
public class A
{
public string name;
public string data;
}
public class B : MarshalByRefObject
{
public A _a;
}
public class C : MarshalByRefObject
{
public A _a;
}
//main program
static void Main(string[] args)
{
B _b = ...
In a C++ physics simulation, I have a class called Circle, and Square. These are Shapes, and have a method called push(), which applies force to it. There is then a special case of Circle, call it SpecialCircle, in which push() should exhibit slightly different properties. But in fact, there is also SpecialSquare() which should exhibit...
am working on a web app in PHP that requires users to register and login with their credentials. However, i am using the singleton pattern in all my PHP class files.
I have something bothering my mind that i would like to clarify. For instance, When the application goes live and we have several users on the site at the same time, doing...
I want to assign a class attribute via a string object - but how?
Example:
class test(object):
pass
a = test()
test.value = 5
a.value
# -> 5
test.__dict__['value']
# -> 5
# BUT:
attr_name = 'next_value'
test.__dict__[attr_name] = 10
# -> 'dictproxy' object does not support item assignment
...
I'm currently writing a C#-class in my ASP.NET (3.5) application to handle all database-queries. Some of the methods are there to make a select-query to the database. Inside the method i simply have a SqlDataReader r = command.ExecuteReader(); to fetch the data.
I now want r to be returned by the method, but when i close the database-co...