Created
October 11, 2013 00:37
-
-
Save cdeutsch/6927917 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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