473,406 Members | 2,281 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,406 software developers and data experts.

How to relate product to category object

J-T

Hello All,

I have two objects one is Product and the otherone is the Category. Category
object is like Food,books,Medicine and etc which has different tax rates .
My product object has properties like name ,price , CategoryID. I need to
create a collection of my products and in this collection I want to have the
Categories tax rate too? How can I relate these two objects together?

Thanks
Feb 9 '06 #1
4 1983
Show me the code for the two classes in question.
Is your collection TYPED ?

Feb 9 '06 #2
J-T
this is my Product object :

public class Product
{
private string m_name;
private double m_price;
private Boolean m_imported;

public Product(string name, double price , Boolean imported)
{
m_name = name;
m_price = price;
m_imported = imported;
}

public string Name
{
set
{
m_name = value;
}
get
{
return m_name;
}
}

public double Price
{
set
{
m_price = value;
}

get
{
return m_price;
}
}

public Boolean Imported
{
set
{
m_imported = value;
}

get
{
return m_imported;
}
}

}

I have not completed the category object ,but here is what I written so far
(which is incomplete)

public class Category

{

private enum Categories {Food=1,Books=2,Medical=3,others=4};
}
As you can see I am trying to create a collection later on . maybe I have to
combine these two classes ,but I don;t know how.

Thanks

"Steven Nagy" <le*********@hotmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Show me the code for the two classes in question.
Is your collection TYPED ?

Feb 9 '06 #3
Could I suggest that you use dataTables instead?
One datatable for each class.
Then, add them to a dataset. You can also define the relationship in
the dataset as well.
Otherwise, try something like this:
Add all your Categories to a collection in the same order that they
appear in the enumeration.
Make the collection a public static variable somewhere you can get to
from your Product class.
Then remove the enum all together from categories.
Add a property to your product class called CategoryID
Add a readonly property to your Product class of type Category. In the
GETTER for the property, check the products CategoryID, and retrieve
the relevent position from the Category collection.

This is kind abstract, but hopefully points you in a useful direction.

Feb 9 '06 #4
J-T
Steven,

Thanks a lot for your help, I will give a try tomorrow (it is 1:00 AM
here:-)) and if there is any moe questions I will let you knw. Thanks for
the help

"Steven Nagy" <le*********@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Could I suggest that you use dataTables instead?
One datatable for each class.
Then, add them to a dataset. You can also define the relationship in
the dataset as well.
Otherwise, try something like this:
Add all your Categories to a collection in the same order that they
appear in the enumeration.
Make the collection a public static variable somewhere you can get to
from your Product class.
Then remove the enum all together from categories.
Add a property to your product class called CategoryID
Add a readonly property to your Product class of type Category. In the
GETTER for the property, check the products CategoryID, and retrieve
the relevent position from the Category collection.

This is kind abstract, but hopefully points you in a useful direction.

Feb 9 '06 #5

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

Similar topics

3
by: J-T | last post by:
Hello All, I have two objects one is Product and the otherone is the Category. Category object is like Food,books,Medicine and etc which has different tax rates . My product object has...
1
by: ollielaroo | last post by:
Hi guys, Firstly I did do a search for this one first but I couldn't find anything related in this forum. I am using Dreamweaver MX and trying to build admin pages for an ASP site. My problem is...
0
by: David Troxell - Encourager Software | last post by:
Product Scope 7 (http://www.encouragersoftware.com/) and Profile Exchanges enhanced with SetupCast publishing methods NOTE: If you are a software author, releasing commercial and/or shareware...
0
by: cdelautour | last post by:
Hi there, I am currently working with the property grid and I am implementing an indexed category system (sorts categories via index before alphabetically). I should say that at this point my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
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,...
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.