Re: A simple employee class : OOP Study
- From: "RSH" <way_beyond_oops@xxxxxxxxx>
- Date: Wed, 14 Dec 2005 16:59:59 -0500
I was playing with the code you provided a bit and it really started to open
my eyes a bit. I experimented a bit and came up with something like this
below. Would this be a good framework, or how would the Orders be
introduced into the mix?
Thanks,
Ron
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassTesting
{
public class Person
{
private string firstName;
private string lastName;
private Address mailingAddress;
private Address billingAddress;
private Address shippingAddress;
private Phone homePhone;
private Phone cellPhone;
public Person()
{
this.mailingAddress = new Address();
this.billingAddress = new Address();
this.shippingAddress = new Address();
this.homePhone = new Phone();
this.cellPhone = new Phone();
}
public Address ShippingAddress
{
get { return shippingAddress; }
}
public Address BillingAddress
{
get { return billingAddress; }
}
public Address MailingAddress
{
get { return mailingAddress; }
}
public Phone HomePhone
{
get { return homePhone; }
}
public Phone CellPhone
{
get { return cellPhone; }
}
public string LastName
{
get { return lastName; }
set { lastName = value; }
}
public string FirstName
{
get { return firstName; }
set { firstName = value; }
}
}
public class Address
{
private string line1;
private string city;
private string state;
private string postalCode;
public string PostalCode
{
get { return postalCode; }
set { postalCode = value; }
}
public string State
{
get { return state; }
set { state = value; }
}
public string City
{
get { return city; }
set { city = value; }
}
public string Line1
{
get { return line1; }
set { line1 = value; }
}
}
public class Phone
{
private int areaCode;
private int prefix;
private int postfix;
private int extension;
public int AreaCode
{
get { return areaCode; }
set { areaCode = value; }
}
public int Prefix
{
get { return prefix; }
set { prefix = value; }
}
public int Postfix
{
get { return postfix; }
set { postfix = value; }
}
public int Extension
{
get { return extension; }
set { extension = value; }
}
public string PhoneNumber
{
get { return "(" + this.AreaCode.ToString() + ")" + this.Prefix.ToString() +
"-" + this.Postfix.ToString(); }
}
}
public class Orders : Person
{
private int orderNumber;
private DateTime orderDate;
private string quantity;
private string product;
public int OrderNumber
{
get { return orderNumber; }
set { orderNumber = value; }
}
public DateTime OrderDate
{
get { return orderDate; }
set { orderDate = value; }
}
public string Quantity
{
get { return quantity; }
set { quantity = value; }
}
public string Product
{
get { return product; }
set { product = value; }
}
}
}
.
- Follow-Ups:
- Re: A simple employee class : OOP Study
- From: JoSkillz
- Re: A simple employee class : OOP Study
- References:
- A simple employee class : OOP Study
- From: RSH
- Re: A simple employee class : OOP Study
- From: Joanna Carter [TeamB]
- Re: A simple employee class : OOP Study
- From: RSH
- Re: A simple employee class : OOP Study
- From: Joanna Carter [TeamB]
- A simple employee class : OOP Study
- Prev by Date: Testing for 2.0
- Next by Date: Re: type conversion issue.
- Previous by thread: Re: A simple employee class : OOP Study
- Next by thread: Re: A simple employee class : OOP Study
- Index(es):
Relevant Pages
|