class

Is it possible to create a class that represents another type in Python, when directly referenced?

So if I have a class like: CustomVal I want to be able to represent a literal value, so like setting it in the constructor: val = CustomVal ( 5 ) val.SomeDefaultIntMethod Basically I want the CustomVal to represent whatever is specified in the constructor. I am not talking about custom methods that know how to deal with CustomVal...

Jquery - Get xth element

For example, I have a div with an id (lets say "the_div"). This div contains an unordered list, and this list has 5 items in it. How would I add a class to the third list item, without any of the list items having a class attached to them? Edit: Even better, how would I change the list item text to equal what number element it was? Th...

Javascript class variable scope using prototype

Hi I'm writing a basic class using prototype.js in which some class vars are set when the class is initialised - the problem is that these variables aren't available to other methods within the class. var Session = Class.create({ initialize: function(){ // define defaults this.source = ''; }, shout: function(){ alert(this.source); }...

How do I reinitialize or reset the properties of a class?

I've created a class with properties that have default values. At some point in the object's lifetime, I'd like to "reset" the object's properties back to what they were when the object was instantiated. For example, let's say this was the class: public class Truck { public string Name = "Super Truck"; public int Tires = 4; pu...

c# object equality for database persistance

I want to learn how others cope with the following scenario. This is not homework or an assignment of any kind. The example classes have been created to better illustrate my question however it does reflect a real life scenario which we would like feedback on. We retrieve all data from the database and place it into an object. A object...

how do I delete/gc an object in Actionscript 3?

I want to delete/force garbage collection on a class instance from inside itself. Obviously, this = null and delete this don't work. Is it any way I can do that, or am I barking up the wrong tree? I'm basically looking for a destructor of some sort.. I have a class instance that attempts to load an XML file, and if the file is not found...

When is it the right time to use C# class library (.dll)?

Hi, I'm a programmer who has never really used .dll files. Of cause, when I need 3rd party software, such as a graphics library, a library to help me create graphs etc. I do add the references/ddl files to my program and use them in my code. Also, it seems like you can use .dll for a lot of different things, so I'd like the topic to co...

HTML Class with <select>

I'm trying to design a Form class in PHP. So far, I have the <input> buttons pretty well working. But the <select> boxes have me stymied. I'm trying to figure out a "generic" way of adding the <option> tags, and am lacking the creativity. I'm not asking for teh codez, but implementation ideas are welcome. ...

Class attribute declaration: private vs public.

What are the advantages of defining a private attribute instead of a public attribute? Why should I have the extra work of creating methods to access and modify privates attributes if I can just make them public? ...

Anonymous vs named inner classes? - best practices?

I have a class, let's call it LineGraph, that renders a line graph. I need to subclass it, but the derived class is only used in one place and is coupled to the class that uses it. So I am using an inner class. I see two ways to do this: Anonymous inner class public class Gui { LineGraph graph = new LineGraph() { // extra ...

Show a message box from a class in c#?

How do you get a class to interact with the form to show a message box. I cannot for the life of me work it out! Thanks, Ash ...

Modeling Classes Based on Table Designs

Is this how one would normally design classes? One class = 1 Table. How about tables that contain a foreign key to another table? Suppose I have the following: PersonTable --------------- person_id name PersonMapTable --------------- map_id type_id (fk) person_id PersonTypeTable ------------------- type_id description parent_type_id ...

Mysql Connection Class

Hi - I'm writing some php code, and I'm frequently accessing my MySQL database to read and update fields. My current code includes a class called dbconnnect, and I use it as follows: class edit_data extends dbconnect { //<some php code> parent::connect(); //<get info from database> parent::disconnect(); //<evaluate data> My questio...

Global Address Class information

Hello all, I am trying to create a generic address class that could be used to store any address from any country. For example here in the UK we have post code where as in USA I think they use Zip code. I have few ideas in mind but I just wanted to see what others think. Thanks. ...

class or ID

Duplicate: Cascading style sheets use “id” or “class” CSS: are class and id interchangeable? div class vs id CSS: div id VS. div class Sometime, when i like to make a selection a add an ID (unique) to something (images) and i used jquery to do domething when hover or clic. But the same thing can be done with cl...

Disposing a form from parent form in C#?

I have a form which will open a new form when one button (form1button) is clicked. And on the child form there will be another button 'form2button'. Now if I click this form2button the new form2 should be disposed. But because the form2 object is created here in form1 class method, I cannot dispose that object in form2 class method (fom2...

c# - How to iterate through classes fields and set properties

I am not sure if this is possible but I want to iterate through a class and set a field member property without referring to the field object explicitly: public class Employee { public Person _person = new Person(); public void DynamicallySetPersonProperty() { MemberInfo[] members = this.GetType().GetMembers(); foreach (...

Page View Class Design

Hi all, Suppose i have the following class. public class Location { public Id { get; set;} public Name { get; set;} } And i have a WebPage called Location that looks like this. txtId txtName txtCountStaffWorkersAtLocation txtCountVehiclesAtLocation txtCountNonStaffWorkersAtLocation txtCountetc listViewPersonnel listVi...

Initiate a class by calling a function that returns an instance of that class - PHP?

class foo(){ function bar() { $classInstance = $this->createClassInstance($params); $result = $classInstance->getSomething(); } function createClassInstance($params) { require 'path/to/class.php'; $myClass = new Class; $myClass->acceptParams($params['1']); $myClass->acceptMoreParams($params[...

Send data between class and form?

Hey guys. The other day, I asked how to create a message box in your class, but one of the answers stated that was it wasn't the correct approach. I understand that this is because it really defeats the point of a class. My program reads word by word from a string file, and checks if each word is in the database. I want to put every wor...