First day

This commit is contained in:
2015-06-18 10:52:10 +02:00
parent b28cbf7ad2
commit 1a61a2a7f7
36 changed files with 1566 additions and 0 deletions

20
Exercise2A/Exercise2A.sln Normal file
View File

@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exercise2A", "Exercise2A\Exercise2A.csproj", "{5C9176E5-EFC6-4B86-857B-C687192BDE9B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5C9176E5-EFC6-4B86-857B-C687192BDE9B}.Debug|x86.ActiveCfg = Debug|x86
{5C9176E5-EFC6-4B86-857B-C687192BDE9B}.Debug|x86.Build.0 = Debug|x86
{5C9176E5-EFC6-4B86-857B-C687192BDE9B}.Release|x86.ActiveCfg = Release|x86
{5C9176E5-EFC6-4B86-857B-C687192BDE9B}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Exercise2A
{
class CustomStack<T>
{
private List<T> items = new List<T>();
public T Peek()
{
T item = items[0];
return item;
}
public T Pop()
{
T item = items[0];
items.RemoveAt(0);
return item;
}
public T Push(T item)
{
items.Insert(0, item);
return item;
}
private bool isEmpty()
{
if (items.Count == 0)
return true;
else
return false;
}
}
}

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5C9176E5-EFC6-4B86-857B-C687192BDE9B}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Exercise2A</RootNamespace>
<AssemblyName>Exercise2A</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CustomStack.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Exercise2A
{
class Program
{
static void Main(string[] args)
{
CustomStack<int> intStack = new CustomStack<int>();
CustomStack<string> stringStack = new CustomStack<string>();
/* ------ INT-STACK --------------- */
intStack.Push(14);
intStack.Push(23);
intStack.Push(34);
intStack.Push(46);
Console.WriteLine(intStack.Peek());
intStack.Pop();
Console.WriteLine(intStack.Peek());
/* ------ STRING-STACK --------------- */
stringStack.Push("Anna");
stringStack.Push("Bertil");
stringStack.Push("Ceasar");
Console.WriteLine(stringStack.Peek());
stringStack.Pop();
Console.WriteLine(stringStack.Peek());
WaitForInput();
}
static void WaitForInput()
{
Console.WriteLine("Press Enter...");
Console.ReadLine();
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Exercise2A")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Exercise2A")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("140ec0cb-89f5-4616-afaa-476f8235b4f5")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]