Skip to content

Commit 9a905f8

Browse files
authored
Add files via upload
1 parent 3d52702 commit 9a905f8

14 files changed

+148
-0
lines changed

LU2/Ex1/Account.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Exercise3
8+
{
9+
class Account
10+
{
11+
double mBalance;
12+
//double Withdraw100(int toWithdraw);
13+
14+
public Account()
15+
{
16+
mBalance = 0.0;
17+
}
18+
19+
public Account(double balance)
20+
{
21+
mBalance = balance;
22+
}
23+
24+
public double Withdraw(int toWithdraw)
25+
{
26+
object obj = new object();
27+
if (mBalance < 0)
28+
{
29+
throw new Exception("Negative balance!!!");
30+
}
31+
lock (obj)
32+
{
33+
if (mBalance >= toWithdraw)
34+
{
35+
Console.WriteLine("Amount before Withdrawal : " + mBalance);
36+
Console.WriteLine("Amount to Withdraw : " + toWithdraw);
37+
mBalance -= toWithdraw;
38+
Console.WriteLine("Amount after Withdrawal : " + mBalance);
39+
return mBalance;
40+
}
41+
else
42+
{
43+
Console.WriteLine("Not enought money! Money in the bank: " + mBalance);
44+
return 0; // transaction rejected
45+
}
46+
}
47+
}
48+
49+
public double GetBalance()
50+
{
51+
return this.mBalance;
52+
}
53+
}
54+
}

LU2/Ex1/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

LU2/Ex1/Ex1.csproj

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{FDFD1F2C-03FD-48DF-AC73-C567D9DB19EF}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Ex1</RootNamespace>
11+
<AssemblyName>Ex1</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Xml" />
42+
</ItemGroup>
43+
<ItemGroup>
44+
<Compile Include="Account.cs" />
45+
<Compile Include="Program.cs" />
46+
<Compile Include="Properties\AssemblyInfo.cs" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<None Include="App.config" />
50+
</ItemGroup>
51+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
52+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
53+
Other similar extension points exist, see Microsoft.Common.targets.
54+
<Target Name="BeforeBuild">
55+
</Target>
56+
<Target Name="AfterBuild">
57+
</Target>
58+
-->
59+
</Project>

LU2/Ex1/bin/Debug/Ex1.exe

6.5 KB
Binary file not shown.

LU2/Ex1/bin/Debug/Ex1.exe.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>

LU2/Ex1/bin/Debug/Ex1.pdb

17.5 KB
Binary file not shown.

LU2/Ex1/bin/Debug/Ex1.vshost.exe

23.7 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
</configuration>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3+
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
4+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5+
<security>
6+
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7+
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
8+
</requestedPrivileges>
9+
</security>
10+
</trustInfo>
11+
</assembly>
Binary file not shown.

0 commit comments

Comments
 (0)