Advertisement
Guest User

Untitled

a guest
Jul 31st, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 4.37 KB | None | 0 0
  1. //File pessoa.d
  2. // Directory: ex3
  3. //Module Directory: include/pes/pessoa.d
  4.  
  5. deprecated("Import include.person instead")
  6. module include.pes.pessoa;
  7. public import include.end.endereco;
  8.  
  9. public class Pessoa
  10. {
  11.  
  12.     private string nome;
  13.     private int idade;
  14.     private string sexo;
  15.     private long CPF;
  16.     private Endereco residencial;
  17.  
  18.     public string getNome()
  19.     {
  20.         return nome;
  21.     }
  22.  
  23.     public void setNome(string nome)
  24.     {
  25.         this.nome = nome;
  26.     }
  27.  
  28.     public int getIdade()
  29.     {
  30.         return idade;
  31.     }
  32.  
  33.     public void setIdade(int idade)
  34.     {
  35.         this.idade = idade;
  36.     }
  37.  
  38.     public string getSexo()
  39.     {
  40.         return sexo;
  41.     }
  42.  
  43.     public void setSexo(string sexo)
  44.     {
  45.         this.sexo = sexo;
  46.     }
  47.  
  48.     public long getCPF()
  49.     {
  50.         return CPF;
  51.     }
  52.  
  53.     public void setCPF(long CPF)
  54.     {
  55.         this.CPF = CPF;
  56.     }
  57.  
  58.     public Endereco getResidencial()
  59.     {
  60.         return residencial;
  61.     }
  62.  
  63.     public void setResidencial(Endereco residencial)
  64.     {
  65.         this.residencial = residencial;
  66.     }
  67. }
  68.  
  69. //////////////////////////////////////////////////////////////
  70. //File person.d
  71. // Directory: ex3
  72. //Module Directory: include/person.d
  73. module  include.person;
  74.  
  75. public import include.pes.pessoa;
  76. ///////////////////////////////////////////
  77. //////////////////////////////////////////
  78. //File endereco.d
  79. // Directory: ex3
  80. //Module Directory: include/end/endereco.d
  81.  
  82. deprecated("Import include.adress instead")
  83. module include.end.endereco;
  84.  
  85. public import std.stdio;
  86.  
  87. public class Endereco
  88. {
  89.     private int numero;
  90.     private string logradouro;
  91.     private string complemento;
  92.     private string bairro;
  93.     private string cidade;
  94.     private string estado;
  95.     private string CEP;
  96.  
  97.     public string getLogradouro()
  98.     {
  99.         return logradouro;
  100.     }
  101.  
  102.     public void setLogradouro(string logradouro)
  103.     {
  104.         this.logradouro = logradouro;
  105.     }
  106.  
  107.     public int getNumero()
  108.     {
  109.         return numero;
  110.     }
  111.  
  112.     public void setNumero(int numero)
  113.     {
  114.         this.numero = numero;
  115.     }
  116.  
  117.     public string getComplemento()
  118.     {
  119.         return complemento;
  120.     }
  121.  
  122.     public void setComplemento(string complemento)
  123.     {
  124.         this.complemento = complemento;
  125.     }
  126.  
  127.     public string getBairro()
  128.     {
  129.         return bairro;
  130.     }
  131.  
  132.     public void setBairro(string bairro)
  133.     {
  134.         this.bairro = bairro;
  135.     }
  136.  
  137.     public string getCidade()
  138.     {
  139.         return cidade;
  140.     }
  141.  
  142.     public void setCidade(string cidade)
  143.     {
  144.         this.cidade = cidade;
  145.     }
  146.  
  147.     public string getEstado()
  148.     {
  149.         return estado;
  150.     }
  151.  
  152.     public void setEstado(string estado)
  153.     {
  154.         this.estado = estado;
  155.     }
  156.  
  157.     public string getCEP()
  158.     {
  159.         return CEP;
  160.     }
  161.  
  162.     public void setCEP(string CEP)
  163.     {
  164.         this.CEP = CEP;
  165.     }
  166. }
  167. ////////////////////////////////////////////
  168. //File adress.d
  169. // Directory: ex3
  170. //Module Directory: include/adress.d
  171.  
  172. module  include.adress;
  173.  
  174. public import include.end.endereco;
  175.  
  176. ////////////////////////////////////////////////////////
  177. //File main.d
  178.  
  179. import include.person; // Not Deprecated Pessoa OK
  180. import include.adress; // Not Deprecated Adrees OK
  181.  
  182. //import include.pes.pessoa; // Deprecated Pessoa OK
  183. //import include.end.endereco; //Deprecated Endereco OK
  184.  
  185. public static void main(string[] args)
  186.     {
  187.         Pessoa[] vetor = new Pessoa[1];
  188.        
  189.         for(int i=0; i<vetor.length;i++)
  190.         {
  191.             vetor[i] = new Pessoa();
  192.             vetor[i].setNome("Chuk Norys");
  193.             vetor[i].setCPF(1234567890);
  194.             vetor[i].setIdade(23);
  195.  
  196.             // Declara e Cria um endereço
  197.             Endereco e = new Endereco();
  198.             e.setCidade("California, ca");
  199.             e.setCEP("10230-400");
  200.  
  201.             // Atribui o endereço à pessoa
  202.             vetor[i].setResidencial(e);
  203.            
  204.             writefln
  205.              (
  206.               "\n\tNome: %s"~
  207.               "\n\tCPF: %s"~
  208.               "\n\tIdade: %s"~
  209.               "\n\tCidade: %s"~
  210.               "\n\tCEP: %s\n",
  211.               vetor[i].getNome(),
  212.               vetor[i].getCPF(),
  213.               vetor[i].getIdade(),
  214.               e.getCidade(),
  215.               e.getCEP()
  216.              );
  217.  
  218.         }
  219.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement