Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Opdracht_0
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             Program myprogram = new Program();
  10.             myprogram.Start();
  11.         }
  12.          void Start()
  13.         {
  14.            
  15.             Persoon persoon1 =LeesPersoon();
  16.             PrintPersoon(persoon1);
  17.         }
  18.         int LeesInt(string vraag)
  19.         {
  20.  
  21.             Console.Write(vraag);
  22.             int nummer = int.Parse(Console.ReadLine());
  23.             return nummer;
  24.         }
  25.         int LeesInt(string vraag, int min, int max)
  26.         {
  27.             Console.Write(vraag);
  28.             int getal = int.Parse(Console.ReadLine());
  29.             while (getal > max || getal < min)
  30.             {
  31.                 Console.Write(vraag);
  32.                 getal = int.Parse(Console.ReadLine());
  33.             }
  34.             return getal;
  35.         }
  36.         string LeesString(string vraag)
  37.         {
  38.             Console.Write(vraag);
  39.             string naam = Console.ReadLine();
  40.             return naam;
  41.         }
  42.         Persoon LeesPersoon()
  43.         {
  44.             Persoon persoon1 = new Persoon();
  45.             persoon1.Voornaam = LeesString("Geef voornaam: ");
  46.             persoon1.Achternaam = LeesString("Geef achternaam: ");
  47.             persoon1.Leeftijd = LeesInt("Geef leeftijd: ");
  48.             persoon1.Woonplaats = LeesString("Geef woonplaats: ");
  49.             return persoon1;
  50.         }
  51.  
  52.         void PrintPersoon(Persoon p)
  53.         {
  54.             Console.WriteLine("\n{0} {1}\n{2} {3}", p.Voornaam,p.Achternaam, p.Leeftijd, p.Woonplaats);
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement