How to refer to other objects?

Greetings,
I'm not sure how objects should refer to other objects.
Example:
Class Automobile needs to refer to objects from other classes, namely to tires, color, motor and company.
So, the way I would do this in C++ or VB is to store all tire, color, motor and company objects into arrays and then store Integer ids in class automobile refering to the index. Like
tiresId
colorId
motorId
companyId
So if I would like to know the name of the company of this automobile, I would have to do the following:
company(automobile.getCompanyId).name
I'm not sure however if this is the right OOP-Way of doing it. Should I rather put object references into class automobile instead so that I would only have to
automobile.getCompany ?
The problem I have with this solution is that I have to read and store the automobile data into files and while it's pretty easy to store an integer-id I'm not sure on how to store object references. They are a little "obscure" to me on this point.
Thanks in advance for any advice.

if you just want to save the type of company, color and so on for every automobile, i think integer ID is a good way,
similar to the existing Color-class with constants:
Color.BLACK, Color.RED, ..
the way with references would also work, then all referenced objects will be saved too,

Similar Messages

  • How to refer the BPM objects in Project to Project.

    Hi,
    I have created some BPM obejects in Project A, i want to use the same Obejct in Project B.
    How to refer the Objects across the Project.
    Could pls some one help me on this.
    Regards,
    Anandh P

    Here are a couple ways to share BPM Objects across projects.
    You can right mouse click a BPM Object in a project and then export it. This will create a zip file that can then be imported into a Module in another project.
    There is a new feature in 10g that allows you to create a dependency between projects. If you define one project to be dependent on another then it can use the BPM Objects found in the other one. To do this, right mouse click the project's name in the Project Navigator tab -> Project Preferences -> Dependency -> select the project you want to be dependent on from the dropdown. This is based on the project's currently visible in the Workspace directory (the directory you are prompted for when Studio first starts up).
    Dan

  • How to refer to an object from within a handler

    So I have a mouse listener that is attached to multiple objects as so:
      for (int i = 0; i < Grids.size(); i++) {
    Grids.get(i).addMouseListener(new GameMouseListener());
    }Now the problem I have is I need to know which of the Objects activated the handler
    obviously this wont work since the var "i" is not defined inside the class and was only used in the previous for loop.
    how to I know using the Handler Which Specific Object has been clicked on.
    public class GameMouseListener implements MouseListener {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (Grid.get(i).isSelected()) {
                    Grid.get(i).unselected();
                } else {
                    Grid.get(i).selected();
            @Override
            public void mousePressed(MouseEvent e) {
            @Override
            public void mouseReleased(MouseEvent e) {
            @Override
            public void mouseEntered(MouseEvent e) {
            @Override
            public void mouseExited(MouseEvent e) {
            }

    user10689232 wrote:
    So I have a mouse listener that is attached to multiple objects as so:No, you have grids.size() amount of listeners, each listening to one object. Just pass the i along to the listener:
    new GameMouseListener(i); // and create that constructor

  • How to relate to other objects...

    Hello there,
    I'm making a Snakes and Ladders game, i'm experienced in programming but not object-orientated programming!
    The class diagram is here:
    http://tinypic.com/view.php?pic=513l8x&s=3
    And the interface so far looks like this:
    http://tinypic.com/view.php?pic=syuzcj&s=3
    So far the interface consists of two instances, gameBoardSession (which is the board itself) and gameControlsSession, the buttons at the bottom that control each turn of play.
    At the moment I have actionListeners on the buttons at the bottom. I've gotten to the stage I want to draw counters on the game board, and create a player object.
    My question is, how do I write the code in the actionListener code to reference the instance gameBoardSession? If I do reference it in the code, obviously it hasn't been declared so it doesn't understand it? So for example, on the "Roll" button I want something like gameBoardSession.setPlayerOnePosition(10), which would obviously set player one to position 10, but it won't know what "gameBoardSession" is in the first place since I haven't declared it?
    Hope i've explained this well, i'm still new to OO programming so I might have got this completely wrong anyway!
    Kind regards,
    Colin

    To get better help sooner, post a SSCCE that clearly demonstrates your problem.
    To post code, use the code tags -- [code]Your Code[/code]will display asYour CodeOr use the code button above the editing area and paste your code between the {code}{code} tags it generates.
    luck, db

  • How to refer field of DataSource in transfer rule for DSO object  in BI 7.0

    hello Gurus,
    I am new to BI 7.
    pls tellme how to refer field of DataSource in transfer rule for DSO object.
    I will assign points to proper answer.
    Praveen.

    hi praveen,
    when u create the transformation for the DSO, it asks for the source. in that you enter your datasource, then you get the datasource fields on one side and the rules in the middle and the DSO objects on the other side. whichever field of DataSource you want to refer in tranformation rule, just connect that field to the rule for the required object of the DSO.
    hope this will help you.
    regards
    vaibhav

  • How to refer to the same JComboBox from object from different panels

    Dear All, i have a question which i could not solve for a past one week.
    In my program i have three panels. In the first panel i have created JComboBox component and throught textfield i add values to it. In my other two panels i make a reference to the JComboBox object which is in my first panel, so that whenever i enter values to it, the same values must be visibile in the other references in second and third panel comboboxes my problem is:
    1. In my second panel JComboBox component reference doesnot appear at all
    2. Can we refer to the same swing component or can we add same swing component in several places
    2.1 If not how to make notify other reference objects when referee' s object state changes.
    thank you in advance

    I'm not PhHeid, but then neither is PhHein.
    Read the API for DefaultComboBoxModel and you'll find how to construct and to modify the state of your model.
    Read the API for JComboBox and you'll find there's a constructor which takes a model as an argument.
    Pass the same model to the constructors of all the JComboBoxes.
    db

  • How do you search through configured Alternate Extensions to correct error message : The phone number or extension has already been assigned to some other object.

    When configuring a new Unity Voicemail Account I receive this message : The phone number or extension has already been assigned to some other object. I understand that this means that the 10 digit number I am trying to configure as the alternate extension for this user is already configured for another object with Unity.
    I need to search by the 10 digit number and determine where it is configured so I can change it and map to the correct end user.
    I have attempted to to search Users via DTMF Access ID using the 10 digit number with nothing being returned via that search.
    How do I Search all of the copnfigured Alternate Extensions within our Unity Server?

    A subscriber info dump is likely the fastest way.  If you're curious regarding other methods, you can also use the Data Link Explorer (CUDLE) tool which is in the Cisco Unity Tools Depot.  All extensions for all objects are referenced in the "DTMFAccessId" table.  The View menu has a Query Builder which you can use to compile a SQL query that searches for a digit string.  It's best to search for both the 10 digit string as well as an abbreviated string as Unity sees them essentially the same and they are usually should be associated with a single subscriber.  Once you find a match, you can use the "ParentObjectId" value associated with the DTMF access ID to look for a matching owner in the "GlobalSubscriber" table.  The ParentObjectId should match the SubscriberObjectId for a subscriber (assuming the DTMF access ID is assigned to a subscriber).  This is the same thing as looking at SQL; however, you are not directly accessing the DB so this is generally considered the safest way to browse and get a feel for where things are.
    Hailey

  • How to Track the table using Trigger or any other Object

    Hi Folks
    I need to audit Inserts, deletions, updates  to inserted into other tracking table. I was planning on using a trigger to do this,
    Can you please help me how can I wright code for trigger for this. or else using any other object we can do this operation.
    can you please help me thanks in advance.
    Thank in advance.

    Also you can use an OUTPUT clause ( need to modify your DML operations)
    create table itest ( i int identity not null primary key, j int not null unique )
    create table #new ( i int not null, j int not null)
    insert into itest (j)
    output inserted.i, inserted.j into #new
    select o.object_id from sys.objects as o
    select * from #new
    drop table #new, itest;
    go
    The example below shows code that uses OUTPUT clause in UPDATE and DELETE statements to insert rows into an audit table.
    create table t ( i int not null );
    create table t_audit ( old_i int not null, new_i int null );
    insert into t (i) values( 1 );
    insert into t (i) values( 2 );
    update t
       set i  = i + 1
    output deleted.i, inserted.i into t_audit
     where i = 1;
    delete from t
    output deleted.i, NULL into t_audit
     where i = 2;
    select * from t;
    select * from t_audit;
    drop table t, t_audit;
    go
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to organize Data Objects and other Objects in SWCV

    Hi,
    I am looking for Best Practices on how to organize data objects in SWCV as well as other objects such as a Distribution Rules.
    We are planning to develop three occasionally connected applications with NW Mobile 7.1 this year and maybe additional one the following year. We will create multiple Standard Data Objects (e.g. Plant, Company Code, Reservations, ...) which are shared in the first set of transactions and in the future transactions.
    I have heard before to separate out Standard Data Objects from Distribution Models and have two different SWCV.
    Should I have a) one SWCV for all current and future Standard Data Objects and one for the distribution rtules or b) should I separate out common data objects into one SWCV, and all transaction-specific data object each into separate SWCV?
    Just wondering if there are any best practices available for this so that I won't run into problems in the future when we want to add more transactions/data objects?
    Any advise is appreciated.
    Thanks,
    W. Berger

    Hi Siva,
    Thanks for quick reply!!
    I have created say SWCV1 for Dataobjects.
    Now i want to create seperate SWCV2 for defining distribution model.
    How i should proceed..I cannot see the uses option while creating new SWCV2  ( Only option i see is  'backward compatibility checkbox : uses NW04/NW04s MI Application')
    where to check the following which you have mentioned?
    SWCV2 was created and inherited SWCV1 in uses tab of SWCV2.
    Thanks in advance!!
    Regards
    Devendra

  • How to recover a state of  one objects threads by other object

    hi everyone
    how to recover a state of one object's threads by other object..
    i am creating a object in that i have 10 thread..... i have started it then i have closed that object ...then i am creating a new object for the same class ...i need to stop those thread which i have started earlier

    saiyath_babuhussain wrote:
    hi everyone
    how to recover a state of one object's threads by other object..Objects don't own threads so that's hard to understand
    >
    i am creating a object in that i have 10 thread..... i have started it then i have closed that object ...then i am creating a new object for the same class ...i need to stop those thread which i have started earlierWe don't so much stop threads as inform them politely that their services are no longer required. When you have a long running thread it's almost always a loop, often with a wait or sleep which causes it to wait until it's activitty is needed.
    So if you want to be able to wind up a thread from another thread then you put a boolean flag in which can break the loop. The other thread then changes that flag and calls interupt() on the thread it's trying to stop. Interupt will kick the thread out of wait or sleep if that's where it is, causing an InterruptedException. On discovering that the flag indicates it should stop, or on catching an InterruptedException the thread should then clean up and finish.
    The master thread can call join on the thread it's stopping if it needs to wait for it to terminate.

  • How to make references to other objects

    Hello, I have a project that I need to do and I am not sure how to start it. I need to have a class that has references to four other objects. I have the class, but am unsure how to do the references. would i use extends? like the class name extends the object name? thanks in advance.

    jn3al wrote:
    i marked it as correct because i thought it was funny that he said that. And to the person talking about driving and other stuff i am not like that when someone cuts me off i just laugh and turn the radio up, I do not cut anyone off and if i do on accident i wave my hand to say thanks. I am not that type of personYour massive overreaction here suggests otherwise.
    i just wanted help without having to read because i read those java things all the time and sometimes i dont understand what it is saying.So you expected someone here to read your mind and know what you read, what you didn't understand, and why you didn't understand it, and to then offer a different explanation? Yeah, that sounds way better than the usual approach of "I read such-and-such, and it said, 'X', but I don't understand what they mean by 'X'. Can you clarify it?" Your mind-reading approach cuts through that annoying communication BS. I like it.
    Im sure this is the simplest thing but for some reason i couldnt think what to do. Ive read posts on here were people ask easier things than that and they get help and not directed to a tutorial.I doubt you've seen enough threads here to have a statistically valid sample. Almost always, if the answer is in a tutorial, the OP will be directed there. There's no reason to repeat what's already been said.
    Not to mention the fact that your question makes no sense whatsoever.
    w/e im going to ask my teacher who helped make java, smarter than anyone here. Odd that you didn't ask him/her in the first place then. And where did you get hold of our IQ test results?

  • How could I pass object to the other object

    Hi,
    How could I pass an object to the new initializing object, so that I can reference to the first object later?

    You mean something like
    MyClass1 myclass1 = new MyClass1();
    MyClass2 myclass2 = new MyClass2(myclass1); // <-- myclass1 is being passed to the constructor of myclass2                                                                                                                                                                                                                                                                                                                                                       

  • How to find object use in other object

    Hi All,
    I want to find one object for example procedure which is used in other object like function,procedure or view.
    How can i find it?
    Thanks in advance.

    user647572 wrote:
    Hi All,
    I want to find one object for example procedure which is used in other object like function,procedure or view.
    How can i find it?
    Thanks in advance.Use DBA_DEPEDENCIES view :
    SQL> create table my_tab (id number);
    Table created.
    SQL> create or replace procedure my_proc
      2  as
      3  p_id number;
      4  begin
      5  select id into p_id from my_tab;
      6  end;
      7  /
    Procedure created.
    SQL> select owner, name, referenced_name from dba_dependencies where referenced_name='MY_TAB';
    OWNER      NAME                 REFERENCED_NAME
    SYS        MY_PROC              MY_TAB
    SQL>

  • How to make GUI components feel the state of other objects?

    I need my JButtons in any place of GUI be enabled or disabled depend on states of several objects or events generated by some other objects. Would you recommend the common approach of how it can be implemented in Swing?

    Sorry for the delay, but the job that pay my bills is keeping me very busy today (taking a short break to reply to you) :)
    Yes, the observers observable pattern is a good way to decouple this (but it could be overkill if you only want to update the status of one button). You will need to have references to the button variable so you can enable it / disable it from another place. For example, let's say you have an Class that extends the Observable and performs your heavy processing on a separate thread (Please not than I don't use generics here, just trying to quickly show you how you may want to do this):
    import java.util.Observable;
    public class TaskMan extends Observable {
        private List comp; 
        public void TaskMan (final List aComp) {
            comp = aComp; // Keep track of the components you want to to toggle on / off
        public void notifyObservers(Object arg) {
                setChanged(true);
                super.notifyObservers(arg);
        public void doIt() {
            new Thread (new Runnable() {
                 public void run() {
                         notifyObservers(comp); // Dissable
                         // Your long consumming task here
                        notifyObservers(comp); // Enable
    }Then you have the Observer class that enable / dissable the buttons and other components:
    import java.util.Observer;
    import java.awt.Component;
    public class MyObserver implements Observer {
         public void update(Object observable, Object arg) {
                 if (! (arg instanceof List)) {
                     return;
                 List list = (List) arg;
                 for (Object elem: list) {
                        Component comp = (Component) elem;
                        EventQueue.invokeLater(new Runnable() {
                               public void run() {
                                     comp.setEnabled(! comp.isEnabled());
    }And finally your main class, where you create and put together your GUI, register your observers and you call your long time consuming job
    import java.util.*;
    public class MyApp {
        public static void main(String [] args) throws Exception {
                  List comps = new ArrayList();
                  JButton aBtn = new JButton("Hey dude!");
                  comps.add(aBtn);
                  TaskMan task = new TaskMan(comps);
                  task.addObserver(new MyObserver());
                  task.doIt();
    }Looks like you have several use cases there, maybe you want to try this approache first for some of them, adding more logic to the observer.
    Please reply back, let me know what you think.
    Regards,
    Jose.

  • How to analyse impact to other objects?

    Hi Friends,
    Suppose i will change any object sometimes definitely that changes impact on other relating objects. Am i right? then my requirement is i have changed one object,now first of all how to find relating objects and then how to analyse impact of those changes.
    Ex: Changes in infoobject that impact on other objects are Cubes, ODS, reports and rules etc.
    Please guide me in this regard <removed by moderator>.
    Thanks,
    Ramki
    Edited by: Siegfried Szameitat on Dec 1, 2008 12:31 PM

    If your upcoming changes will affect any of the compounded objects then rest assured that the concerned InfoObjects shouldn't contain any data otherwise your infoobjects will be unstable and would be throwing error after activation...
    as far as the related objects are concerned then just remember the thumb rule(extended star schema):
    All the objects in BW are related to each other by a key: Fact table is linked to Dim tab by Dim ID,,Dim Tables linked to SID tables by Surrogate ID(SID) and this SID points to Master data tables(Text, attr and Hier)
    So going from Fact table to Master data table, if you make any changes in fact table (including or excluding Key figures) or in Dim table (including/excuding Characteristics) then you have to activate your master data so  that SIDs will be generated and vice-versa
    Edited by: Alok Kashyap on Dec 1, 2008 12:46 PM

Maybe you are looking for

  • Premiere Elements 11 start up error - Windows 7, 64 bit

    Premiere Elements 11 was working fine until 1 week ago.  Now I get an error on start up that says "Display Driver Intel HD Graphics is out of date. . . ". Then it loads very slowly. Once loaded, Premiere does not show the video though appears to be r

  • JDBC sender: after read insert records into another table

    Hi all, I send records from a SQL view (not a table) to RFC via proxy method. After reading a record from the view I would like to move this record to a database table called CHECKED. Can anyone provide me a solution for this or is this impossible. (

  • Mail converts jpg/gif images to tiff

    I have a friend who has an ibook running panther. When she tries to forward an email message that contains jpg or gif attachments, Mail converts them to tiff, which causes problems for her windows bound friends, and also increases the message size by

  • Error in accounting interface at the time of Invoice posting

    Hi..   Im getting this error at the time of Invoice Posting . "Error in accounting interface " Plz guide me regards Deepa

  • Actionlistener passing variables to frame?

    Hi guys. I have an actionlistener to run my file chooser dialog. When i have selected a file, how do i pass the files name back to the JFrame please? Thanks N