Commit f6a878d6 authored by Maxime POULAIN's avatar Maxime POULAIN
Browse files

add tps

parent 5779d972

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TP1", "TP1\TP1.csproj", "{043ED44D-63A5-4447-8615-4FE77C4D17A1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{043ED44D-63A5-4447-8615-4FE77C4D17A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{043ED44D-63A5-4447-8615-4FE77C4D17A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{043ED44D-63A5-4447-8615-4FE77C4D17A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{043ED44D-63A5-4447-8615-4FE77C4D17A1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DF85AB4C-207E-43F0-83A5-0146CC8C623B}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
\ No newline at end of file
using System;
namespace TP1
{
class Program
{
static void Main(string[] args)
{
var hour = DateTime.Now.Hour;
var name = Environment.UserName;
var day = DateTime.Now.DayOfWeek;
if (hour > 9 && hour < 18 && day >= DayOfWeek.Monday && day <= DayOfWeek.Friday)
{
Console.Write($"Bonjour {name}, il est {hour}h !");
}
else if ((hour <= 9 || hour >= 18) && day >= DayOfWeek.Monday && day < DayOfWeek.Friday)
{
Console.Write($"Bonsoir {name}, il est {hour}h !");
}
else
{
Console.Write($"Bon weekend {name} !");
}
Console.ReadLine();
}
}
}
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("TP1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TP1")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[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("043ed44d-63a5-4447-8615-4fe77c4d17a1")]
// 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")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{043ED44D-63A5-4447-8615-4FE77C4D17A1}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>TP1</RootNamespace>
<AssemblyName>TP1</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</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|AnyCPU' ">
<PlatformTarget>AnyCPU</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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TP2", "TP2\TP2.csproj", "{7ACAA02C-776C-4327-B335-E3AEE7BF2E4E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7ACAA02C-776C-4327-B335-E3AEE7BF2E4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7ACAA02C-776C-4327-B335-E3AEE7BF2E4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7ACAA02C-776C-4327-B335-E3AEE7BF2E4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7ACAA02C-776C-4327-B335-E3AEE7BF2E4E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D98F6BA8-80DD-4CF9-BFFA-C625F41F6546}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TP2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(CalculSommeEntiers(1, 10));
Console.WriteLine(CalculSommeEntiers(1, 100));
Console.WriteLine(CalculMoyenne(new List<double> { 4, 5, 8, 9, 6 }));
ProcessLists();
Console.ReadLine();
}
private static int CalculSommeEntiers(int deb, int fin)
{
int counter = 0;
for (int i = deb; i <= fin; i++)
{
counter += i;
}
return counter;
}
private static double CalculMoyenne(ICollection<double> doubles)
{
return doubles.Average();
}
private static void ProcessLists()
{
List<int> list3 = new List<int>();
List<int> list5 = new List<int>();
for (int i = 0; i < 100; i++)
{
if (i % 3 == 0)
{
list3.Add(i);
}
if (i % 5 == 0)
{
list5.Add(i);
}
}
Console.WriteLine(Enumerable.Intersect(list3, list5).Sum());
}
}
}
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("TP2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TP2")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[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("7acaa02c-776c-4327-b335-e3aee7bf2e4e")]
// 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")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7ACAA02C-776C-4327-B335-E3AEE7BF2E4E}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>TP2</RootNamespace>
<AssemblyName>TP2</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</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|AnyCPU' ">
<PlatformTarget>AnyCPU</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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TP3", "TP3\TP3.csproj", "{088010BC-707E-448D-9B9E-866818DC348A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{088010BC-707E-448D-9B9E-866818DC348A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{088010BC-707E-448D-9B9E-866818DC348A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{088010BC-707E-448D-9B9E-866818DC348A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{088010BC-707E-448D-9B9E-866818DC348A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {05952EDC-EB30-479E-A466-65966C96FE89}
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using System.Text;
namespace TP3
{
public class CurrentAccount : IBankAccount
{
private decimal _balance;
public decimal Balance { get => _balance; private set => _balance = value; }
public void PayIn(decimal amount)
{
Balance += amount;
Console.WriteLine($"Dépot de {amount} sur le compte courrant : Balance {Balance}");
}
public bool Withdraw(decimal amount)
{
Balance -= amount;
Console.WriteLine($"Retrait de {amount} sur le compte courrant : Balance {Balance}");
return true;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace TP3
{
public interface IBankAccount
{
decimal Balance { get; }
void PayIn(decimal amount);
bool Withdraw(decimal amount);
}
}
using System;
using System.Globalization;
namespace TP3
{
class Program
{
static void Main(string[] args)
{
IBankAccount current = new CurrentAccount();
IBankAccount savings = new SavingAccount();
CultureInfo.CurrentCulture = new CultureInfo("fr-FR");
current.PayIn(500);
savings.PayIn(500);
Console.WriteLine($"Épargne : {savings.Balance:C}");
Console.WriteLine($"Courrant : {current.Balance.ToString("C",CultureInfo.CurrentCulture)}");
current.Withdraw(600);
savings.Withdraw(600);
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace TP3
{
public class SavingAccount : IBankAccount
{
private decimal _balance;
public decimal Balance
{
get => _balance;
private set
{
if (value < 0)
{
_balance = 0;
}
else {
_balance = value;
}
}
}
public void PayIn(decimal amount)
{
Balance += amount;
Console.WriteLine($"Dépot de {amount} sur le compte d'épargne : Balance {Balance}");
}
public bool Withdraw(decimal amount)
{
if(amount < Balance)
{
Balance -= amount;
Console.WriteLine($"Retrait de {amount} sur le compte d'épargne : Balance {Balance}");
}
else
{
Console.WriteLine("Retrait impossible pour cause de solde insuffisant");
}
return true;
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment