Advertisement
Nannoka

Lista de exercícios 2 Porta

Mar 4th, 2015
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 KB | None | 0 0
  1. //Classe program//
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace ConsoleApplication3
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             Console.WriteLine(" *Opções* ");
  16.             Console.WriteLine("Para abrir digite 1");
  17.             Console.WriteLine("Para fechar digite 2");
  18.             Console.WriteLine("Para colorir digite 3");
  19.             Console.WriteLine("Para Alterar altura digite 4");
  20.             Console.WriteLine("Para alterar largura digite 5");
  21.             Console.WriteLine("Para alterar espessura digite 6");
  22.             Console.WriteLine("Para sair digite 0");
  23.  
  24.             try
  25.             {
  26.                 double op = double.Parse(Console.ReadLine());
  27.             }
  28.             catch {
  29.                 Console.Write("Opção incorreta!");
  30.             }
  31.             {
  32.  
  33.                 throw;
  34.             }
  35.  
  36.             Porta p = new Porta();
  37.             p.Aberta = false;
  38.             p.Cor = "Branco";
  39.             p.DimensaoX = 180;
  40.             p.DimensaoY = 4;
  41.             p.DimensaoZ = 80;
  42.  
  43.             p.Abrir();
  44.             p.Fechar();
  45.             p.Pintar("Verde");
  46.             p.Pintar("Azul");
  47.  
  48.             p.DimensaoX = 170;
  49.  
  50.             string isAberta = p.EstaAberta() ? "Sim" : "Não";
  51.             Console.WriteLine("A porta está aberta? " + isAberta);
  52.  
  53.  
  54.         }
  55.     }
  56. }
  57.  
  58.  
  59. //Classe porta//
  60.  
  61.  
  62. using System;
  63. using System.Collections.Generic;
  64. using System.Linq;
  65. using System.Text;
  66. using System.Threading.Tasks;
  67.  
  68. namespace ConsoleApplication3
  69. {
  70.     class Porta
  71.     {
  72.         public Boolean Aberta { get; set; }
  73.         public string Cor { get; set; }
  74.         public double DimensaoX { get; set; }
  75.         public double DimensaoY { get; set; }
  76.         public double DimensaoZ { get; set; }
  77.  
  78.         public Porta(double Porta, string Cor, double DimensaoX, double DimensaoY, double DimensaoZ)
  79.         {
  80.             this.Aberta = Aberta;
  81.             this.Cor = Cor;
  82.             this.DimensaoX = DimensaoX;
  83.             this.DimensaoY = DimensaoY;
  84.             this.DimensaoZ = DimensaoZ;
  85.  
  86.         }
  87.  
  88.         public void Abrir()
  89.         {
  90.  
  91.             this.Aberta = true;
  92.  
  93.         }
  94.  
  95.         public void Fechar()
  96.         {
  97.             this.Aberta = false;
  98.         }
  99.  
  100.         public void Pintar(string novaCor)
  101.         {
  102.             this.Cor = novaCor;
  103.         }
  104.  
  105.         public Boolean EstaAberta()
  106.         {
  107.             return Aberta;
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement