class

how to reference a higher class within an anonymous class

I have this code: public class Home extends Activity{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //... //at some point I have s.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){ @Override public ...

Somehow not assigning a class with Ruby

On runtime, my code often come into an undefined method error for the method mate. As far as I can figure, a Person somehow slips through the cracks sometime along the code's exucution, and manages not to have an allele assigned to it. Code (disclaimer, not the best formatted): class Allele attr_accessor :c1, :c2 def initialize(c1...

Independent instances of 'random'

The below code attempts to illustrate what I want. I basically want two instances of "random" that operate independently of each other. I want to seed "random" within one class without affecting "random" in another class. How can I do that? class RandomSeeded: def __init__(self, seed): import random as r1 self.random...

How does the Objective-C runtime instantiate the root metaclass and other class descriptions?

I'm trying to implement a basic object-oriented ANSI C runtime and using Objective-C as a guide. They're seems to be three parts. A Class Description, Class Interface, and Class Implementation. In order for the Class Interface to be instantiated, the familiar method of using the Class object to instantiate one's object can only happen i...

Break method chaining in php

Hi I am using method chaining for my class structure. So my problem is that , how could i break my chain when error occurred in some function. Below is my code: <?php class demo { public __construct() { $this->a='a'; $this->b='b'; $this->error = false; } p...

calling a method from another method in same PHP class

Hi, I'm trying to use a method from within another method in a class. I don't have much experience in PHP5 OOP, and I looked around for answers, but couldn't find any. I'm trying to use getClientInfo() in sendRequest(), which is in the same class. class DomainHandler { public static function getClientInfo($db, $client_id) { ...

Setting A Default Variable Value In The Construct Of A PHP Class

I'm having difficulties in setting the values of a private variable in the construct of a class i'm working on... Can anyone spot where i'm going wrong? function __contruct($brokerId){ parent::__contstruct($brokerId); $this->_coverSummaryPoints = array('option1' => array('bullet point 1', ...

How can I apply a CSS class to an element with a given id, without modifying the element?

I have a page that looks like: <div id="header">...</div><div id="navigation">...</div> similar for body and footer. I'd like to use a grid system to style the page, all of which seem to rely on giving the divs mentioned a class based on their presentation. But I don't want to do this (and can't because of the way the markup is generate...

Is it reasonable to have a fair amount of public properties in a class?

Or in more specific words, is it "ok" to not be relying on setters and getters? I'm dealing with a class that checks the availability of rooms and sets public properties of which there are more than a dozen. Things such as: unitNumber roomTypes ( array ) codeCorporate codeGroup numberKids numberAdults numberRooms currency minRate maxR...

Class Diagram with aggregation and generalization

Hi I am working on a university project and i have the following problem i can not figure out. I have a class Called Employee from this i generalize two classes Contractor employee and Permanent Employee. Now i have a team that is made by both types of Employee so i am planning to use aggregation. Do i have to connect the team cla...

How do I declare a default constructor for sub-class of abstract class?

The following doesn't work for me in Java. Eclipse complains that there is no such constructor. I've added the constructor to the sub-class to get around it, but is there another way to do what I'm trying to do? public abstract class Foo { String mText; public Foo(String text) { mText = text; } } public class Bar...

Defining a class in a JSP

Please don't punch me in the face! I know this flies in the face of good design, but I'm simply writing a test page to demonstrate something. Our webapp module (correctly) has no direct access to our domain classes. I don't want to create a whole class outside of the JSP, since the page is just for demonstration purposes, and I don't wan...

AS3 Scope issue, How do I dynamically create a new MC in a package/class?

Hello all, Thanks very much for your time! Here is my question,... public function addNewMc():void{ var newMC:MovieClip= new MovieClip(); this.addChild(newMC); } public function removeOldMc(newMC):void{ this.removeChild(newMC); } How can I create a new MovieClip within a method, which can be used throughout the class, with...

C#: Class for decoding Quoted-Printable encoding?

Is there an existing class in C# that can convert Quoted-Printable encoding to String? Click on the above link to get more information on the encoding. The following is quoted from the above link for your convenience. Any 8-bit byte value may be encoded with 3 characters, an "=" followed by two hexadecimal digits (0–9 or A–F) ...

NSClassFromString returns nil

Why does NSClassFromString return nil ? As per the definition it has to return class name. How should i take care to rectify this problem. since i need to instantiate a class from string and call the method which is in the class using the instance created. This is how my code looks like. id myclass = [[NSClassFromString(@"Class_from_St...

Keep client side class changes between ASP.Net postbacks?

I'm dynamically binding tables and sub tables using nested listviews. On the client side I have a piece of jQuery that is toggling the visiblity of TRs witin the tables in order to provide a group expand / contract view option. On postback I'm obviously loosing my class changes that I have applied via jQuery. I'm wondering what the best...

Describing class relationships in ruby

I've never done any straight ruby coding - only worked with the Rails framework. I am not sure how to describe the relationships between Classes, other than inheritance relationships. For example, a School object may have many Student objects. I would like to be able to make calls like "myschool.student[2].first_name" and "mystudent.sc...

Error when calling the metaclass bases: function() argument 1 must be code, not str

I tried to subclass threading.Condition earlier today but it didn't work out. Here is the output of the Python interpreter when I try to subclass the threading.Condition class: >>> import threading >>> class ThisWontWork(threading.Condition): ... pass ... Traceback (most recent call last): File "<stdin>", line 1, in <module> Type...

How can I share common methods between view controllers?

I have an iPhone app, it has two separate MKMapView components in different views, however, many of the actions I will perform with the two views are the same. How do I write the methods once but use them in both view controllers? An example is I have a button which is disabled in both views until the user performs a certain action, I ...

How do you extend class level methods to a separate module in Rails?

Given a situation such as: module Extension def self.included(recipient) recipient.extend(ModelClassMethods) end module ModelClassMethods def self.msg puts 'Hi from module' end end end class B include Extension end Why is B.msg not available? >> B.msg NoMethodError: undefined method `msg' for B:Class ...