473,770 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1330
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*****@hotmai l.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*****@hotmai l.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*****@hotmai l.com> wrote in message
news:bt******* ***@news2.tilbu 1.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*******@disc ussions.microso ft.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*****@hotmai l.com> wrote in message
news:bt******* ***@news2.tilbu 1.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*****@bigpon d.com> schreef in bericht
news:Jr******** **********@news-server.bigpond. net.au...

"Arjen" <bo*****@hotmai l.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*****@hotmai l.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*******@disc ussions.microso ft.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*****@hotmai l.com> wrote in message
news:bt******* ***@news2.tilbu 1.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
2812
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
11384
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 building the database: 3:ERROR: table "country" does not exist 6:ERROR: table "customer" does not exist 11:ERROR: table "product" does not exist 15:ERROR: table "license" does not exist 19:ERROR: table "enduser" does not exist 24:ERROR: ...
175
11511
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 think is PostgreSQL would have less USP's (Uniqe Selling Points
6
1628
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 ds_formData As New DataSet ' ' Fill Line Of Business ' cmd_selectCommand.CommandText = "BENESP_GetLinesOfBusiness" da_formData.FillSchema(ds_formData, SchemaType.Source, "LinesOfBusiness")
5
2631
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 offered. If I set IsNested to false or default, then it is included in the XSD. Is this a bug or by design? Corno
7
2740
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 relation 149064743 failed 2004-04-14 12:23:32 ERROR: Relation "tmp_table1" does not exist 2004-04-14 12:23:32 ERROR: Relation "tmp_table1" does not exist So turn on debugging options and have that's what i got:
11
1530
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 correctly). For example, when I do this, I use the keyword (?) "prototype": function Example() {
0
2912
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 generate a report from data in grid Files. It displays like (e.g. is Col1 is selected): Col1 Count ---------------------- Val1 x Val2 y .....
9
1534
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
10099
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10036
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7451
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.