473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

help: composition & aggregation etc static non-static error message

to learn java I'm working on an eco-system simulation, the source's at:
http://www.geocities.com/cjavacjava/src/

class XYZcoordinates has three fields: int x,y,z

class Cat inherits from abstract class LifeForm

each cat needs one and only one XYZcoordinates object

I think I know what I want, but keep getting errors about
static/non-static references to static/non-static variables.

please do look at the code :)
ja***@mail.com
Jul 17 '05 #1
1 2041
ja***@mail.com (javac) wrote in news:64d923a9.0403291144.418bc7f5
@posting.google.com:
http://www.geocities.co


Your method "main" within "Cat" does not instantiate any objects of class
"Cat". Thus, how does the compiler know which "Cat" object your are talking
about (since you don't have any)?

You are missing:

Cat mycat = new Cat();

and also:

System.out.println(mycat.xyz.getX()) ;

Note that you have to have a "Cat" to do something with its "XYZcoordinates"
object.

Once you get the above working:

Shouldn't your "LifeForm" class have a getter for xyz ? Maybe setters too?

Good Luck!

--
Ian Shef 805/F6 * These are my personal opinions
Raytheon Company * and not those of my employer.
PO Box 11337 *
Tucson, AZ 85734-1337 *
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DKode | last post by:
I think i have a good handle on aggregation/composition. can someone tell me if i am headed in the right direction with my analysis below: We have the following objects: Employee...
1
by: Chris K | last post by:
I am relatively new to C++ and hope that this question is relevant. I have spent some time at the local library and some time on dejanews, but have no decided to go ahead with my question, since...
4
by: cmrchs | last post by:
Hi, how do I implement aggregation and how composition in C# ? When I say : an Airplane has a Pilot then I use aggregation but when I say : an Airplane has a Cockpit then I use composition. How...
4
by: Frederik Vanderhaegen | last post by:
Hi, Can anyone explain me the difference between aggregation and composition? I know that they both are "whole-part" relationships and that composition parts are destroyed when the composition...
2
by: Heinz Ketchup | last post by:
Hello, I'm looking to bounce ideas off of anyone, since mainly the idea of using Multiple Virtual Inheritance seems rather nutty. I chalk it up to my lack of C++ Experience. Here is my...
2
by: Gary Wessle | last post by:
Hi what is the difference "in code writing" between aggregation and composition? is the following correct? aggregation (life time of both objects are independent). class A{ /* ... */ };...
4
by: fireball | last post by:
hi, I got confused for a moment about creating data structure for UML composition (strong aggregation) relation one-to-many. I used Rose/DataModeler to do so. <filled_diamond>-------- I...
4
by: Salman | last post by:
The most confusing concept i have seen in OOP is the difference between Association, Composition and Aggregation. Anyone please tell me whats the actual difference between these three using...
7
by: dev_15 | last post by:
Hi, just a simple question in an OO design in C++ if i am using composition to model a relationship i would have the object as a member(or pointer member) of the class ie class Airport {...
4
by: Kay Schluehr | last post by:
As you know, there is no operator for function composition in Python. When you have two functions F and G and want to express the composition F o G you have to create a new closure lambda...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.