Skip to content

Commit b8a9271

Browse files
committed
VT29_Curso
Videotutorial nº 29 del curso de Visual C#. Archivos de prácticas
1 parent 7094e76 commit b8a9271

17 files changed

+683
-0
lines changed

CursoCS_VT29/Cartas/Cartas.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cartas", "Cartas\Cartas.csproj", "{D32FF1B5-9B38-4ED6-A6A2-3F749F0EF8BC}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Release|Any CPU = Release|Any CPU
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{D32FF1B5-9B38-4ED6-A6A2-3F749F0EF8BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13+
{D32FF1B5-9B38-4ED6-A6A2-3F749F0EF8BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
14+
{D32FF1B5-9B38-4ED6-A6A2-3F749F0EF8BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
15+
{D32FF1B5-9B38-4ED6-A6A2-3F749F0EF8BC}.Release|Any CPU.Build.0 = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal

CursoCS_VT29/Cartas/Cartas/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>

CursoCS_VT29/Cartas/Cartas/App.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Application x:Class="Cartas.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
StartupUri="MainWindow.xaml">
5+
<Application.Resources>
6+
7+
</Application.Resources>
8+
</Application>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace Cartas
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}

CursoCS_VT29/Cartas/Cartas/Carta.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace Cartas
2+
{
3+
class Carta
4+
{
5+
private readonly Palo palo;
6+
private readonly Valor valor;
7+
8+
public Carta(Palo p, Valor v)
9+
{
10+
this.palo = p;
11+
this.valor = v;
12+
}
13+
14+
public override string ToString()
15+
{
16+
string resultado = string.Format("{0} de {1}", this.valor, this.palo);
17+
return resultado;
18+
}
19+
20+
public Palo PaloCarta()
21+
{
22+
return this.palo;
23+
}
24+
25+
public Valor ValorCarta()
26+
{
27+
return this.valor;
28+
}
29+
}
30+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.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>{D32FF1B5-9B38-4ED6-A6A2-3F749F0EF8BC}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Cartas</RootNamespace>
11+
<AssemblyName>Cartas</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
15+
<WarningLevel>4</WarningLevel>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<PlatformTarget>AnyCPU</PlatformTarget>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<PlatformTarget>AnyCPU</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<ItemGroup>
37+
<Reference Include="System" />
38+
<Reference Include="System.Data" />
39+
<Reference Include="System.Xml" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Core" />
42+
<Reference Include="System.Xml.Linq" />
43+
<Reference Include="System.Data.DataSetExtensions" />
44+
<Reference Include="System.Xaml">
45+
<RequiredTargetFramework>4.0</RequiredTargetFramework>
46+
</Reference>
47+
<Reference Include="WindowsBase" />
48+
<Reference Include="PresentationCore" />
49+
<Reference Include="PresentationFramework" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<ApplicationDefinition Include="App.xaml">
53+
<Generator>MSBuild:Compile</Generator>
54+
<SubType>Designer</SubType>
55+
</ApplicationDefinition>
56+
<Compile Include="Palo.cs" />
57+
<Compile Include="Valor.cs" />
58+
<Page Include="MainWindow.xaml">
59+
<Generator>MSBuild:Compile</Generator>
60+
<SubType>Designer</SubType>
61+
</Page>
62+
<Compile Include="App.xaml.cs">
63+
<DependentUpon>App.xaml</DependentUpon>
64+
<SubType>Code</SubType>
65+
</Compile>
66+
<Compile Include="Mano.cs" />
67+
<Compile Include="MainWindow.xaml.cs">
68+
<DependentUpon>MainWindow.xaml</DependentUpon>
69+
<SubType>Code</SubType>
70+
</Compile>
71+
</ItemGroup>
72+
<ItemGroup>
73+
<Compile Include="Pack.cs" />
74+
<Compile Include="Carta.cs" />
75+
<Compile Include="Properties\AssemblyInfo.cs">
76+
<SubType>Code</SubType>
77+
</Compile>
78+
<Compile Include="Properties\Resources.Designer.cs">
79+
<AutoGen>True</AutoGen>
80+
<DesignTime>True</DesignTime>
81+
<DependentUpon>Resources.resx</DependentUpon>
82+
</Compile>
83+
<Compile Include="Properties\Settings.Designer.cs">
84+
<AutoGen>True</AutoGen>
85+
<DependentUpon>Settings.settings</DependentUpon>
86+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
87+
</Compile>
88+
<EmbeddedResource Include="Properties\Resources.resx">
89+
<Generator>ResXFileCodeGenerator</Generator>
90+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
91+
</EmbeddedResource>
92+
<None Include="Properties\Settings.settings">
93+
<Generator>SettingsSingleFileGenerator</Generator>
94+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
95+
</None>
96+
<AppDesigner Include="Properties\" />
97+
</ItemGroup>
98+
<ItemGroup>
99+
<None Include="App.config" />
100+
</ItemGroup>
101+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
102+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
103+
Other similar extension points exist, see Microsoft.Common.targets.
104+
<Target Name="BeforeBuild">
105+
</Target>
106+
<Target Name="AfterBuild">
107+
</Target>
108+
-->
109+
</Project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<Window x:Class="Cartas.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
Title="Juego Cartas" Height="450" Width="750">
5+
<Window.Resources>
6+
<Style x:Key="BorderStyle" TargetType="Border">
7+
<Setter Property="BorderThickness" Value="3"/>
8+
<Setter Property="BorderBrush" Value="CadetBlue"/>
9+
<Setter Property="Background" Value="Bisque"/>
10+
</Style>
11+
</Window.Resources>
12+
13+
<Grid>
14+
<Grid.RowDefinitions>
15+
<RowDefinition Height="*"/>
16+
<RowDefinition Height="2*"/>
17+
<RowDefinition Height="*"/>
18+
<RowDefinition Height="15*"/>
19+
<RowDefinition Height="2*"/>
20+
</Grid.RowDefinitions>
21+
<TextBlock Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24" Margin="300,0,300,295" Grid.RowSpan="3" ><Run Language="es-es" Text="Juego Cargas"/><LineBreak/><Run Language="es-es"/></TextBlock>
22+
<Grid Grid.Row="3">
23+
<Grid.RowDefinitions>
24+
<RowDefinition Height="20*"/>
25+
<RowDefinition Height="14*"/>
26+
<RowDefinition Height="265*"/>
27+
</Grid.RowDefinitions>
28+
<Grid.ColumnDefinitions>
29+
<ColumnDefinition Width="*"/>
30+
<ColumnDefinition Width="8*"/>
31+
<ColumnDefinition Width="*"/>
32+
<ColumnDefinition Width="8*"/>
33+
<ColumnDefinition Width="*"/>
34+
<ColumnDefinition Width="8*"/>
35+
<ColumnDefinition Width="*"/>
36+
<ColumnDefinition Width="8*"/>
37+
<ColumnDefinition Width="*"/>
38+
</Grid.ColumnDefinitions>
39+
<TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" FontSize="18" Margin="57,-2,57,11.84" Grid.RowSpan="2" ><Run Text="No"/><Run Language="es-es" Text="rte"/></TextBlock>
40+
<TextBlock Grid.Row="0" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Margin="67,-2,67,11.84" Grid.RowSpan="2" ><Run Text="S"/><Run Language="es-es" Text="ur"/></TextBlock>
41+
<TextBlock Grid.Row="0" Grid.Column="5" HorizontalAlignment="Center" VerticalAlignment="Bottom" FontSize="18" Margin="64,-2,63,11.84" Grid.RowSpan="2" ><Run Text="E"/><Run Language="es-es" Text="ste"/></TextBlock>
42+
<TextBlock Grid.Row="0" Grid.Column="7" HorizontalAlignment="Center" VerticalAlignment="Bottom" FontSize="18" Margin="46,-2,52,12" Grid.RowSpan="2" Width="63" ><Run Language="es-es" Text="Oeste"/></TextBlock>
43+
<Border Grid.Row="1" Grid.Column="1" Style="{StaticResource BorderStyle}" Grid.RowSpan="2">
44+
<TextBlock x:Name="norte" Margin="10" HorizontalAlignment="Left" FontSize="13" />
45+
</Border>
46+
<Border Grid.Row="1" Grid.Column="3" Style="{StaticResource BorderStyle}" Grid.RowSpan="2">
47+
<TextBlock x:Name="sur" Margin="10" HorizontalAlignment="Left" FontSize="13" />
48+
</Border>
49+
<Border Grid.Row="1" Grid.Column="5" Style="{StaticResource BorderStyle}" Grid.RowSpan="2">
50+
<TextBlock x:Name="este" Margin="10" HorizontalAlignment="Left" FontSize="13" />
51+
</Border>
52+
<Border Grid.Row="1" Grid.Column="7" Style="{StaticResource BorderStyle}" Grid.RowSpan="2">
53+
<TextBlock x:Name="oeste" Margin="10" HorizontalAlignment="Left" FontSize="13" />
54+
</Border>
55+
</Grid>
56+
<Button Grid.Row="4" Content="Repartir" HorizontalAlignment="Center" Width="60" Height="25" Click="dealClick"/>
57+
</Grid>
58+
</Window>
59+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace Cartas
17+
{
18+
/// <summary>
19+
/// Interaction logic for MainWindow.xaml
20+
/// </summary>
21+
public partial class MainWindow : Window
22+
{
23+
public const int NumManos = 4;
24+
private Pack pack = null;
25+
private Mano[] manos = { new Mano(), new Mano(), new Mano(), new Mano() };
26+
27+
public MainWindow()
28+
{
29+
InitializeComponent();
30+
}
31+
32+
private void dealClick(object sender, RoutedEventArgs e)
33+
{
34+
try
35+
{
36+
pack = new Pack();
37+
38+
for (int numMano = 0; numMano < NumManos; numMano++)
39+
{
40+
manos[numMano] = new Mano();
41+
for (int numCartas = 0; numCartas < Mano.TamMano; numCartas++)
42+
{
43+
Carta repartoCarta = pack.RepartirCartaDePack();
44+
manos[numMano].AdcartaAMano(repartoCarta);
45+
}
46+
}
47+
48+
norte.Text = manos[0].ToString();
49+
sur.Text = manos[1].ToString();
50+
este.Text = manos[2].ToString();
51+
oeste.Text = manos[3].ToString();
52+
}
53+
catch (Exception ex)
54+
{
55+
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
56+
}
57+
}
58+
}
59+
}

CursoCS_VT29/Cartas/Cartas/Mano.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
3+
namespace Cartas
4+
{
5+
class Mano
6+
{
7+
public const int TamMano = 10;
8+
private Carta[] cartas = new Carta[TamMano];
9+
private int contadorCartas = 0;
10+
11+
public void AdcartaAMano(Carta cardDealt)
12+
{
13+
if (this.contadorCartas >= TamMano)
14+
{
15+
throw new ArgumentException("Demasiadas Cartas");
16+
}
17+
this.cartas[this.contadorCartas] = cardDealt;
18+
this.contadorCartas++;
19+
}
20+
21+
public override string ToString()
22+
{
23+
string resultado = "";
24+
foreach (Carta carta in this.cartas)
25+
{
26+
resultado += carta.ToString() + "\n";
27+
}
28+
29+
return resultado;
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)