Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projeto Hospedagem do Hotel #148

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions trilha-net-explorando-desafio-main/DesafioProjetoHospedagem.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
</PropertyGroup>

</Project>
21 changes: 21 additions & 0 deletions trilha-net-explorando-desafio-main/Models/Pessoa.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace DesafioProjetoHospedagem.Models;

public class Pessoa
{
public Pessoa() { }

public Pessoa(string nome)
{
Nome = nome;
}

public Pessoa(string nome, string sobrenome)
{
Nome = nome;
Sobrenome = sobrenome;
}

public string Nome { get; set; }
public string Sobrenome { get; set; }
public string NomeCompleto => $"{Nome} {Sobrenome}".ToUpper();
}
56 changes: 56 additions & 0 deletions trilha-net-explorando-desafio-main/Models/Reserva.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
namespace DesafioProjetoHospedagem.Models
{
public class Reserva
{
public List<Pessoa> Hospedes { get; set; }
public Suite Suite { get; set; }
public int DiasReservados { get; set; }
public int ValorDesconto{ get; set; }

public Reserva() { }

public Reserva(int diasReservados)
{
DiasReservados = diasReservados;
ValorDesconto = 1;
}

public void CadastrarHospedes(List<Pessoa> hospedes)
{
if (hospedes.Count > Hospedes.Count)
{
Hospedes = hospedes;
}
else
{
throw new Exception ("O quarto não comporta tantos hóspedes");
}
}

public void CadastrarSuite(Suite suite)
{
Suite = suite;
}

public int ObterQuantidadeHospedes()
{
if (Hospedes != null)
{
return Hospedes.Count();
}
return 0;
}

public decimal CalcularValorDiaria()
{

decimal valor = Suite.ValorDiaria * DiasReservados;

if (DiasReservados >= 10)
{
valor *= ValorDesconto;
}
return valor;
}
}
}
18 changes: 18 additions & 0 deletions trilha-net-explorando-desafio-main/Models/Suite.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace DesafioProjetoHospedagem.Models
{
public class Suite
{
public Suite() { }

public Suite(string tipoSuite, int capacidade, decimal valorDiaria)
{
TipoSuite = tipoSuite;
Capacidade = capacidade;
ValorDiaria = valorDiaria;
}

public string TipoSuite { get; set; }
public int Capacidade { get; set; }
public decimal ValorDiaria { get; set; }
}
}
25 changes: 25 additions & 0 deletions trilha-net-explorando-desafio-main/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Text;
using DesafioProjetoHospedagem.Models;

Console.OutputEncoding = Encoding.UTF8;

// Cria os modelos de hóspedes e cadastra na lista de hóspedes
List<Pessoa> hospedes = new List<Pessoa>();

Pessoa p1 = new Pessoa(nome: "Hóspede 1");
Pessoa p2 = new Pessoa(nome: "Hóspede 2");

hospedes.Add(p1);
hospedes.Add(p2);

// Cria a suíte
Suite suite = new Suite(tipoSuite: "Premium", capacidade: 3, valorDiaria: 30);

// Cria uma nova reserva, passando a suíte e os hóspedes
Reserva reserva = new Reserva(diasReservados: 5);
reserva.CadastrarSuite(suite);
reserva.CadastrarHospedes(hospedes);

// Exibe a quantidade de hóspedes e o valor da diária
Console.WriteLine($"Hóspedes: {reserva.ObterQuantidadeHospedes()}");
Console.WriteLine($"Valor diária: {reserva.CalcularValorDiaria()}");
21 changes: 21 additions & 0 deletions trilha-net-explorando-desafio-main/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# DIO - Trilha .NET - Explorando a linguagem C#
www.dio.me

## Desafio de projeto
Para este desafio, você precisará usar seus conhecimentos adquiridos no módulo de explorando a linguagem C#, da trilha .NET da DIO.

## Contexto
Você foi contratado para construir um sistema de hospedagem, que será usado para realizar uma reserva em um hotel. Você precisará usar a classe Pessoa, que representa o hóspede, a classe Suíte, e a classe Reserva, que fará um relacionamento entre ambos.

O seu programa deverá cálcular corretamente os valores dos métodos da classe Reserva, que precisará trazer a quantidade de hóspedes e o valor da diária, concedendo um desconto de 10% para caso a reserva seja para um período maior que 10 dias.

## Regras e validações
1. Não deve ser possível realizar uma reserva de uma suíte com capacidade menor do que a quantidade de hóspedes. Exemplo: Se é uma suíte capaz de hospedar 2 pessoas, então ao passar 3 hóspedes deverá retornar uma exception.
2. O método ObterQuantidadeHospedes da classe Reserva deverá retornar a quantidade total de hóspedes, enquanto que o método CalcularValorDiaria deverá retornar o valor da diária (Dias reservados x valor da diária).
3. Caso seja feita uma reserva igual ou maior que 10 dias, deverá ser concedido um desconto de 10% no valor da diária.


![Diagrama de classe estacionamento](diagrama_classe_hotel.png)

## Solução
O código está pela metade, e você deverá dar continuidade obedecendo as regras descritas acima, para que no final, tenhamos um programa funcional. Procure pela palavra comentada "TODO" no código, em seguida, implemente conforme as regras acima.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"DesafioProjetoHospedagem/1.0.0": {
"runtime": {
"DesafioProjetoHospedagem.dll": {}
}
}
}
},
"libraries": {
"DesafioProjetoHospedagem/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net6.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"DesafioProjetoHospedagem/1.0.0": {
"runtime": {
"DesafioProjetoHospedagem.dll": {}
}
}
}
},
"libraries": {
"DesafioProjetoHospedagem/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("DesafioProjetoHospedagem")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("DesafioProjetoHospedagem")]
[assembly: System.Reflection.AssemblyTitleAttribute("DesafioProjetoHospedagem")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Gerado pela classe WriteCodeFragment do MSBuild.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f58073f4375208841869d33cccd03edd40f34f690a45238af6b3e6375d4728ed
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net6.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = DesafioProjetoHospedagem
build_property.ProjectDir = C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f6b514b6ac586e6b09a803e1d93d515b9c151228ebb186960537b2a2264f53f4
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\bin\Debug\net6.0\DesafioProjetoHospedagem.exe
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\bin\Debug\net6.0\DesafioProjetoHospedagem.deps.json
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\bin\Debug\net6.0\DesafioProjetoHospedagem.runtimeconfig.json
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\bin\Debug\net6.0\DesafioProjetoHospedagem.dll
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\bin\Debug\net6.0\DesafioProjetoHospedagem.pdb
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net6.0\DesafioProjetoHospedagem.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net6.0\DesafioProjetoHospedagem.AssemblyInfoInputs.cache
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net6.0\DesafioProjetoHospedagem.AssemblyInfo.cs
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net6.0\DesafioProjetoHospedagem.csproj.CoreCompileInputs.cache
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net6.0\DesafioProjetoHospedagem.dll
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net6.0\refint\DesafioProjetoHospedagem.dll
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net6.0\DesafioProjetoHospedagem.pdb
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net6.0\DesafioProjetoHospedagem.genruntimeconfig.cache
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net6.0\ref\DesafioProjetoHospedagem.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6e8aafcc4efd3f2e3bd669b93f6fc9bfa3a7a48c8f344a8784c5c003bc6d66ff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("DesafioProjetoHospedagem")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("DesafioProjetoHospedagem")]
[assembly: System.Reflection.AssemblyTitleAttribute("DesafioProjetoHospedagem")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Gerado pela classe WriteCodeFragment do MSBuild.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f58073f4375208841869d33cccd03edd40f34f690a45238af6b3e6375d4728ed
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = DesafioProjetoHospedagem
build_property.ProjectDir = C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
447076ed0e2cadbe8eb468d4041b4718526796259c7b6b9f0c0c1e73afc6aeef
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\bin\Debug\net8.0\DesafioProjetoHospedagem.exe
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\bin\Debug\net8.0\DesafioProjetoHospedagem.deps.json
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\bin\Debug\net8.0\DesafioProjetoHospedagem.runtimeconfig.json
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\bin\Debug\net8.0\DesafioProjetoHospedagem.dll
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\bin\Debug\net8.0\DesafioProjetoHospedagem.pdb
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.AssemblyInfoInputs.cache
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.AssemblyInfo.cs
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.csproj.CoreCompileInputs.cache
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.dll
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net8.0\refint\DesafioProjetoHospedagem.dll
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.pdb
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.genruntimeconfig.cache
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\trilha-net-explorando-desafio-main\obj\Debug\net8.0\ref\DesafioProjetoHospedagem.dll
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\bin\Debug\net8.0\DesafioProjetoHospedagem.exe
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\bin\Debug\net8.0\DesafioProjetoHospedagem.deps.json
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\bin\Debug\net8.0\DesafioProjetoHospedagem.runtimeconfig.json
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\bin\Debug\net8.0\DesafioProjetoHospedagem.dll
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\bin\Debug\net8.0\DesafioProjetoHospedagem.pdb
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.AssemblyInfoInputs.cache
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.AssemblyInfo.cs
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.csproj.CoreCompileInputs.cache
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.dll
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\obj\Debug\net8.0\refint\DesafioProjetoHospedagem.dll
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.pdb
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\obj\Debug\net8.0\DesafioProjetoHospedagem.genruntimeconfig.cache
C:\Users\Nyan\Documents\Program\Desafios DIO\Desafio Hospedagem de Hotel\trilha-net-explorando-desafio-main\obj\Debug\net8.0\ref\DesafioProjetoHospedagem.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b2670e1af556a6205618b674388580e56c67ea4f087d7caf611f2407f4803022
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading