Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add the BNRItem class from Chapter 2

  • Loading branch information...
commit d39c5d8a67ea491d2f0f20e2885634eac53d5f67 1 parent abf9880
Paul Betts authored
20 BNRItem/BNRItem.sln
View
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BNRItem", "BNRItem\BNRItem.csproj", "{393FB1DB-637E-4C58-A155-E43529678EA8}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {393FB1DB-637E-4C58-A155-E43529678EA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {393FB1DB-637E-4C58-A155-E43529678EA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {393FB1DB-637E-4C58-A155-E43529678EA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {393FB1DB-637E-4C58-A155-E43529678EA8}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = BNRItem\BNRItem.csproj
+ EndGlobalSection
+EndGlobal
52 BNRItem/BNRItem/BNRItem.cs
View
@@ -0,0 +1,52 @@
+using System;
+
+namespace BNRItem
+{
+ public class BNRItem
+ {
+ public string ItemName { get; set; }
+ public string SerialNumber { get; set; }
+ public int ValueInDollars { get; set; }
+ public DateTime DateCreated { get; protected set; }
+
+ public BNRItem ()
+ {
+ DateCreated = DateTime.UtcNow;
+ }
+
+ public string Description {
+ get {
+ return String.Format("{0} ({1}) Worth ${2}, recorded on {3}",
+ ItemName, SerialNumber, ValueInDollars, DateCreated);
+ }
+ }
+
+ public override string ToString ()
+ {
+ return Description;
+ }
+
+ public static BNRItem RandomItem()
+ {
+ var adjectives = new[] { "Fluffy", "Rusty", "Shiny" };
+ var nouns = new[] { "Bear", "Spork", "Mac" };
+
+ var prng = new Random();
+ var name = String.Format("{0} {1}",
+ adjectives[prng.Next() % adjectives.Length], nouns[prng.Next() % nouns.Length]);
+
+ var val = prng.Next() % 100;
+ var sn = String.Format("{0}{1}{2}{3}{4}",
+ '0' + prng.Next() % 10, 'A' + prng.Next() % 26,
+ '0' + prng.Next() % 10, 'A' + prng.Next() % 26,
+ '0' + prng.Next() % 10);
+
+ return new BNRItem() {
+ ItemName = name,
+ SerialNumber = sn,
+ ValueInDollars = val,
+ };
+ }
+ }
+}
+
42 BNRItem/BNRItem/BNRItem.csproj
View
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{393FB1DB-637E-4C58-A155-E43529678EA8}</ProjectGuid>
+ <ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <RootNamespace>BNRItem</RootNamespace>
+ <AssemblyName>BNRItem</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Core" />
+ <Reference Include="monotouch" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <Compile Include="BNRItem.cs" />
+ </ItemGroup>
+</Project>
Please sign in to comment.
Something went wrong with that request. Please try again.