Skip to content

Instantly share code, notes, and snippets.

@cdeutsch
Created October 11, 2013 00:37
Show Gist options
  • Select an option

  • Save cdeutsch/6927917 to your computer and use it in GitHub Desktop.

Select an option

Save cdeutsch/6927917 to your computer and use it in GitHub Desktop.
using System;
using System.ComponentModel;
namespace XamarinStore
{
public enum ProductType
{
Shirt,
Plushie
}
public enum ProductSex
{
Either,
Mens,
Womens
}
public enum SizeType
{
Small,
Medium,
Large,
XLarge,
XXLarge
}
public class Product
{
string name;
public string Name {
set { name = value; }
get {
switch (Sex) {
case ProductSex.Mens:
return string.Format ("Men's {0}", name);
case ProductSex.Womens:
return string.Format ("Women's {0}", name);
default:
return name;
}
}
}
public string Description { get; set; }
public string ImageUrl { get; set; }
public double Price { get; set; }
public ProductType ProductType { get; private set; }
public SizeType Size { get; set; }
public ShirtColor Color { get; set; }
public ProductSex Sex { get; set; }
public Product (ProductType type)
{
ProductType = type;
}
public string PriceDescription {
get {
return Price == 0 ? "Free" : Price.ToString ("C");
}
}
public string SizeDescription {
get {
string sizeDescription;
switch (Size) {
case SizeType.Small:
sizeDescription = "Tamarin (Small)";
break;
case SizeType.Medium:
sizeDescription = "Chimpanzee (Medium)";
break;
case SizeType.Large:
sizeDescription = "Orangutan (Large)";
break;
case SizeType.XLarge:
sizeDescription = "Gorilla (X-Large)";
break;
case SizeType.XXLarge:
sizeDescription = "King Kong (XX-Large)";
break;
default:
sizeDescription = "Null";
break;
}
return sizeDescription;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment