473,399 Members | 3,038 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,399 software developers and data experts.

The relation between objects

Hello,

Let's say that we have an array "persons" with person objects.
We also have an array with "books" with book objects.
We have from a single book only one copy.
This means that it is possible that a persons loans one or more books.

All right, let's say that we have a person ("Name: James; Age: 25") that
loans 2 books ("Title: My first book; ISBN: 23213 & Title: My last book;
ISBN: 89899").

We save our objects... (inside arrays not inside a database)
How can I see which persons have loans which books?
I understand the relations between the objects... but don't know how to get
them back.

Can you give me some sample code?

Many thanks!
Nov 15 '05 #1
6 1316
Arjen,

Sounds like a Homework question to me. Why don't you post some code,
explain were you are stuck and the group will try to help.

Sorry no free rides :)

--
Glen Jones MCSD

"Arjen" <bo*****@hotmail.com> wrote in message
news:bt**********@news2.tilbu1.nb.home.nl...
Hello,

Let's say that we have an array "persons" with person objects.
We also have an array with "books" with book objects.
We have from a single book only one copy.
This means that it is possible that a persons loans one or more books.

All right, let's say that we have a person ("Name: James; Age: 25") that
loans 2 books ("Title: My first book; ISBN: 23213 & Title: My last book;
ISBN: 89899").

We save our objects... (inside arrays not inside a database)
How can I see which persons have loans which books?
I understand the relations between the objects... but don't know how to get them back.

Can you give me some sample code?

Many thanks!

Nov 15 '05 #2

"Arjen" <bo*****@hotmail.com> wrote in message
news:bt**********@news2.tilbu1.nb.home.nl...
Hello,

Let's say that we have an array "persons" with person
objects.

Ok, an array of person objects:

Person [] people = new Person[MAX_PEOPLE];

We also have an array with "books" with book objects.

Ok, an array of book objects:

Book [] books = new Book[MAX_BOOKS];

We have from a single book only one copy.

This means that it is possible that a persons loans one or
more books.

If you have designed the Person class to have such a relationship with
objects of the Book class. This is the crucial thing you need to learn: how
to design such classes, and how to establish such relationships between such
classes.

The only way to 'link' these two collections:

Person [] people = new Person[MAX_PEOPLE];
Book [] books = new Book[MAX_BOOKS];

is via some explicit connection between the contained objects. So, for
example, if the classes were something like the following:

class Person
{
...
bool OwnsBook(String bookName) { ... }
...
}

class Book
{
...
// Could use property - this keeps example simple
String BookName() { ... }
...
}

You might then be able to do something like:

...
if (people[idx].OwnsBook(books[idx].BookName())
...

Remember, this is merely one of *many* possibilities !!!

All right, let's say that we have a person ("Name: James;
Age: 25") that loans 2 books ("Title: My first book; ISBN:
23213 & Title: My last book; ISBN: 89899").

We save our objects... (inside arrays not inside a database)

How can I see which persons have loans which books?

It depends entirely how you have designed your classes, and established any
relationships between them. There is no single, general way that this can be
accomplished.

I understand the relations between the objects... but don't
know how to get them back.

Can you give me some sample code?


The response, by Ivan Krivyakov, to your earlier 'Re: Object and objects'
query provided you with an excellent coding example. I suggest that you
spend more time studying it, and try to understand why things were done the
way they were. You can then apply the principles learned from this code to
your Person / Books problem.

I hope this helps.

Anthony Borla

P.S.

This *is* a genuine attempt to help you. You will, very likely, waste a lot
of time, and find yourself quite frustrated, if you you don't try to
understand the basic principles of object design. Once these ideas are clear
to you, any coding then becomes fairly trivial.
Nov 15 '05 #3
Jax
I agree, this guy has been posting for weeks and not once
showing us an example of what he's doing.
He wanted the syntax for Xml Serialization, i gave it to
him, not a word of thanks (to anyone, not just me) and
then a new question a few hours later asking the same
question.

Some advice for Arjan, go to msdn.com, search on google,
if you have Visual Studio use the help files contained,
with all of the information available you will be able to
solve all of your problems.
Failing that buy a book on the topic of C# (i recommend
the Wrox press ones) and above all say thankyou to people
when they're trying to help you.

jax

-----Original Message-----
Arjen,

Sounds like a Homework question to me. Why don't you post some code,explain were you are stuck and the group will try to help.

Sorry no free rides :)

--
Glen Jones MCSD

"Arjen" <bo*****@hotmail.com> wrote in message
news:bt**********@news2.tilbu1.nb.home.nl...
Hello,

Let's say that we have an array "persons" with person objects. We also have an array with "books" with book objects.
We have from a single book only one copy.
This means that it is possible that a persons loans one or more books.
All right, let's say that we have a person ("Name: James; Age: 25") that loans 2 books ("Title: My first book; ISBN: 23213 & Title: My last book; ISBN: 89899").

We save our objects... (inside arrays not inside a database) How can I see which persons have loans which books?
I understand the relations between the objects... but
don't know how toget
them back.

Can you give me some sample code?

Many thanks!

.

Nov 15 '05 #4
Thanks!

"Jax" <an*******@discussions.microsoft.com> schreef in bericht
news:05****************************@phx.gbl...
I agree, this guy has been posting for weeks and not once
showing us an example of what he's doing.
He wanted the syntax for Xml Serialization, i gave it to
him, not a word of thanks (to anyone, not just me) and
then a new question a few hours later asking the same
question.

Some advice for Arjan, go to msdn.com, search on google,
if you have Visual Studio use the help files contained,
with all of the information available you will be able to
solve all of your problems.
Failing that buy a book on the topic of C# (i recommend
the Wrox press ones) and above all say thankyou to people
when they're trying to help you.

jax

-----Original Message-----
Arjen,

Sounds like a Homework question to me. Why don't you

post some code,
explain were you are stuck and the group will try to help.

Sorry no free rides :)

--
Glen Jones MCSD

"Arjen" <bo*****@hotmail.com> wrote in message
news:bt**********@news2.tilbu1.nb.home.nl...
Hello,

Let's say that we have an array "persons" with person objects. We also have an array with "books" with book objects.
We have from a single book only one copy.
This means that it is possible that a persons loans one or more books.
All right, let's say that we have a person ("Name: James; Age: 25") that loans 2 books ("Title: My first book; ISBN: 23213 & Title: My last book; ISBN: 89899").

We save our objects... (inside arrays not inside a database) How can I see which persons have loans which books?
I understand the relations between the objects... but

don't know how to
get
them back.

Can you give me some sample code?

Many thanks!

.

Nov 15 '05 #5
> Remember, this is merely one of *many* possibilities !!!

I have get some other answers from other persons too...
And of cource this helps!

Thanks for your answer.

"Anthony Borla" <aj*****@bigpond.com> schreef in bericht
news:Jr******************@news-server.bigpond.net.au...

"Arjen" <bo*****@hotmail.com> wrote in message
news:bt**********@news2.tilbu1.nb.home.nl...
Hello,

Let's say that we have an array "persons" with person
objects.

Ok, an array of person objects:

Person [] people = new Person[MAX_PEOPLE];

We also have an array with "books" with book objects.


Ok, an array of book objects:

Book [] books = new Book[MAX_BOOKS];

We have from a single book only one copy.

This means that it is possible that a persons loans one or
more books.


If you have designed the Person class to have such a relationship with
objects of the Book class. This is the crucial thing you need to learn:

how to design such classes, and how to establish such relationships between such classes.

The only way to 'link' these two collections:

Person [] people = new Person[MAX_PEOPLE];
Book [] books = new Book[MAX_BOOKS];

is via some explicit connection between the contained objects. So, for
example, if the classes were something like the following:

class Person
{
...
bool OwnsBook(String bookName) { ... }
...
}

class Book
{
...
// Could use property - this keeps example simple
String BookName() { ... }
...
}

You might then be able to do something like:

...
if (people[idx].OwnsBook(books[idx].BookName())
...

Remember, this is merely one of *many* possibilities !!!

All right, let's say that we have a person ("Name: James;
Age: 25") that loans 2 books ("Title: My first book; ISBN:
23213 & Title: My last book; ISBN: 89899").

We save our objects... (inside arrays not inside a database)

How can I see which persons have loans which books?

It depends entirely how you have designed your classes, and established

any relationships between them. There is no single, general way that this can be accomplished.

I understand the relations between the objects... but don't
know how to get them back.

Can you give me some sample code?

The response, by Ivan Krivyakov, to your earlier 'Re: Object and objects'
query provided you with an excellent coding example. I suggest that you
spend more time studying it, and try to understand why things were done

the way they were. You can then apply the principles learned from this code to
your Person / Books problem.

I hope this helps.

Anthony Borla

P.S.

This *is* a genuine attempt to help you. You will, very likely, waste a lot of time, and find yourself quite frustrated, if you you don't try to
understand the basic principles of object design. Once these ideas are clear to you, any coding then becomes fairly trivial.

Nov 15 '05 #6

"Arjen" <bo*****@hotmail.com> wrote in message
news:bt**********@news2.tilbu1.nb.home.nl...
Thanks!

please note - the thanks is not required, and is often implied (and those
that demand or expect it are often associated with the lower tiers of the
food chain).

some consider the gratuitous response to be nothing more than noise. do it
if you want, but otherwise feel no obligation.

rlf


"Jax" <an*******@discussions.microsoft.com> schreef in bericht
news:05****************************@phx.gbl...
I agree, this guy has been posting for weeks and not once
showing us an example of what he's doing.
He wanted the syntax for Xml Serialization, i gave it to
him, not a word of thanks (to anyone, not just me) and
then a new question a few hours later asking the same
question.

Some advice for Arjan, go to msdn.com, search on google,
if you have Visual Studio use the help files contained,
with all of the information available you will be able to
solve all of your problems.
Failing that buy a book on the topic of C# (i recommend
the Wrox press ones) and above all say thankyou to people
when they're trying to help you.

jax

-----Original Message-----
Arjen,

Sounds like a Homework question to me. Why don't you

post some code,
explain were you are stuck and the group will try to help.

Sorry no free rides :)

--
Glen Jones MCSD

"Arjen" <bo*****@hotmail.com> wrote in message
news:bt**********@news2.tilbu1.nb.home.nl...
> Hello,
>
> Let's say that we have an array "persons" with person

objects.
> We also have an array with "books" with book objects.
> We have from a single book only one copy.
> This means that it is possible that a persons loans one

or more books.
>
> All right, let's say that we have a person ("Name:

James; Age: 25") that
> loans 2 books ("Title: My first book; ISBN: 23213 &

Title: My last book;
> ISBN: 89899").
>
> We save our objects... (inside arrays not inside a

database)
> How can I see which persons have loans which books?
> I understand the relations between the objects... but

don't know how to
get
> them back.
>
> Can you give me some sample code?
>
> Many thanks!
>
>
.


Nov 15 '05 #7

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

Similar topics

11
by: Milind | last post by:
Hi, I was trying to implement a composition relation, somthing of the following type: class A { public: class B {
3
by: Terrence Brannon | last post by:
I don't know what Postgres considers a relation and had no intention of creating one when piping my schema to it... I always DROP TABLE before CREATE TABLE, so here are the ERRORS emitted when...
175
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I...
6
by: Brian Henry | last post by:
Here's an example of the code.. I have two combo boxes on screen that when one's selection is change the other's items will be updated to reflect the change (based on a relation) Private...
5
by: Corno | last post by:
Hi all, If I want to provide a typed dataset from a webservice and if that dataset has relations that are nested (isNested=True), then the relations(keyrefs) are not available in the XSD that is...
7
by: Juris Krumins | last post by:
I have a problem with postgresql tables. periodicaly, I would say frequently about 5-10 time per hour i have such errors in my server log file: 2004-04-14 12:23:32 ERROR: cache lookup of...
11
by: shypen42 | last post by:
Hi all, I'm very confused by the relation between "prototype" and that "Prototype.js" library that seems to be used quite a lot (not by knowledgeable people from this group if I understood...
0
by: Ambica Jain | last post by:
I have a data grid called Files, which has some columns like FileName, Col1, Col2, ... , Col8. Then i have a combobox which allows user to select from Col1 to Col8 and based on this selection, i...
9
by: Miro | last post by:
VS2008 I have created 3 tables. Vendors Customers PhoneNumbers each have their own key Vendor has: VendorID - int unique identifier Customer has: CustomerID - int unique identifier
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.