objects

Comparing two objects using an equals method, Java

I have an array of objects that I want to compare to a target object. I want to return the number of objects that exactly match the target object. Here is my count method: public int countMatchingGhosts(Ghost target) { int count=0; for (int i=0;i<ghosts.length;i++){ if (ghosts[i].equals(target)); ...

Foo* a=new Foo; and Foo* b=new Foo();

Possible Duplicate: Do the parentheses after the type name make a difference with new? What is the difference between the following : Foo* a=new Foo; and Foo* b=new Foo(); in the following code? Can anyone tell me what exactly happens when these two statements are executed? #include <iostream> using namespace std; class Foo...

Returning a reference to an object in PHP

I'm using PHP 5.2.14 and PearLog 1.12.3. The latest documentation from the singleton method in Log.php (PEARLog) states: You MUST call this method with the $var = &Log::singleton()syntax. Without the ampersand (&) in front of the method name, you will not get a reference; you will get a copy. However, doing so generates the...

Java Modulo Help

public void turnRight() { int direction=getDirection(); if (direction==3) direction=0; else direction++; this.setDirection(direction); So I have this method that, when called, increments direction by 1. However, the max value should be 3, so if direction is equal to 3 and the meth...

Not sure why I have "EXC Bad Access" error.

Hello everyone! I've programmed for a while in Java and .Net, but never really used C or Objective C. I'm still trying to understand a few concepts. I was working on a simple program just to see how I can make an array of structures. Which I believe I got right. I'm having a hard time figuring out how to access the subclasses and store ...

LINQ double left join

I've got a students class with a name, a blogEntries class with a student name and entry title, and a blogAssignments class with an assignment name. I'd like to show ALL students and alongside them the blogEntries they created whose title matches the blogAssignments.assignmentName. I've got the following LINQ query but I can't figure o...

using cmake to link object files into lib.xxxx.a file

I've got a list of object files that I want to package in a library. How do I do this? I thought I could use ADD_LIBRARY ...

Creating Custom Objects at runtime in C#

I want to create custom objects in C# at runtime, the objects will have properties imported from an xml file. The xml file looks something like this: <field name="FirstName" value="Joe" type="string" /> <field name="DateAdded" value="20090101" type="date" /> I would like to create objects in c# that have properties such as FirstName a...

PhoneGap.exec() passing objects between JS and Obj-C

The only way I found to passing objects between the JS and Obj-C it's by encoding the JS object by using JSON.stringify() and pass the json string to PhoneGap.exec PhoneGap.exec('Alarm.update',JSON.stringify(list)); ... and rebuild the object in Obj-C: NSString *jsonStr = [arguments objectAtIndex:0]; jsonStr = [jsonStr stringByRe...

MVC Model View for Complex Object

I am very new to MVC and I have a Model like this User : FirstName : TextBox LastName : TexBox User Commitee : [CheckBox Textbox] [CheckBox Textbox] [CheckBox Textbox] I store if user is in committee in a separate table.I need to insert selected check box value and related text box to database.How can I achieve this ? Can this be po...

Comparing objects memory address, Java

Robot r1,r2,r3; r1=new Robot("Huey",2,3); r2=new Robot("Louie",5,4); r3=new Robot("Louie",5,4); r1=r2; r2=r3; r3=r1; System.out.print(r1==r2); So this program prints false, but I thought it would print true. Its asking if the memory address of r1 is the same as r2. Well r1 is set to equal r2, then r2 is changed to r3, but that shouldn'...

Using variables in methods in objective c

Is there any way define a object in a method, call a method of another object, and in that method use the first object: -(IBAction)method{ class * instance = [[class alloc] initWithValue:value]; [instance method]; } The method defined in class.m file: -(void) method { instance.value = someOtherValue; } ...

is there some kind of object representation software that you can control remotely through some kind of api?

What it should do is represent objects of various types, but you should be able to control the representation remotely through some network-based api from another application (xml idealy). What I want to do is to have the logic of my application written in C++, where many kinds of "objects" are involved. I'd like to be able to manage the...

how to dynamically create methods to operate on class objects initialized at runtime

I have a class, say class AddElement{ int a,b,c; } With methods to set/get a,b,c... My question is definitely a logic question - say I implement AddElement as follows: int Value=1; Value+=AddElement.get_a()+AddElement.get_b()+AddElement.get_b(); Now imagine I want to do the above except 'a,b,c' are now arrays, and instead of '...

Python Object Storage Memory/Dict/DB/Other Options

I'm currently writing a python application that will take a directory of text files and parse them into custom python objects based on the the attributes specified in the text file. As part of my application, I compare the current loaded object data set to a previous dataset (same format) and scan it for possible duplicates, conflicts, u...

Can we avoid npe while checking for null in nested java objects?

1) if(null != parentObj.childObj) 2) if(parentObj.childObj != null) Do you think that "1" will avoid a potential null pointer exception in the case where 'parentObj' is null, in contrast to "2"? ...

Why is Java's polymorphism failing to catch the right method when choosing between object and vector?

I have two similar methods. One is intended to handle objects, the other vectors: @SuppressWarnings("unused") private void printRows(PrintWriter out, Vector<?> dataOb, String[] columns, String[] columnType, Hashtable<?, ?> columnAccessors, String trOptions, String tdOptions) throws ServletException { ...

Is it possible to append functions to a JS class that have access to the class's private variables?

I have an existing class I need to convert so I can append functions like my_class.prototype.my_funcs.afucntion = function(){ alert(private_var);} after the main object definition. What's the best/easiest method for converting an existing class to use this method? Currently I have a JavaScript object constructed like this: var my_class ...

Why does this attempt to output an arrayList object to a JtextArea not work?

ArrayList list_of_employees = new ArrayList(); @Action public void reportAllEmployeesClicked(java.awt.event.ActionEvent evt) { this.outputText.setText(""); int i=0; //JOptionPane.showMessageDialog(null,"test Employee list print"); ListIterator list_ir = list_of_employees.listIterator(); //list_of_employees is of ...

How do I insert data into object tables that have refs to others?

I'm new in Oracle and I really don't have a clear idea how to do this. The database is this one... CREATE OR REPLACE TYPE personUdt4 AS OBJECT( pid varchar(11), firstName varchar(20), lastName varchar(20), dob date) NOT FINAL; / CREATE OR REPLACE TYPE locationUdt4 AS OBJECT( street varchar(30), bldg varchar(5), room varchar(5)...