Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Opdracht_0
- {
- class Program
- {
- static void Main()
- {
- Program myprogram = new Program();
- myprogram.Start();
- }
- void Start()
- {
- Persoon persoon1 =LeesPersoon();
- PrintPersoon(persoon1);
- }
- int LeesInt(string vraag)
- {
- Console.Write(vraag);
- int nummer = int.Parse(Console.ReadLine());
- return nummer;
- }
- int LeesInt(string vraag, int min, int max)
- {
- Console.Write(vraag);
- int getal = int.Parse(Console.ReadLine());
- while (getal > max || getal < min)
- {
- Console.Write(vraag);
- getal = int.Parse(Console.ReadLine());
- }
- return getal;
- }
- string LeesString(string vraag)
- {
- Console.Write(vraag);
- string naam = Console.ReadLine();
- return naam;
- }
- Persoon LeesPersoon()
- {
- Persoon persoon1 = new Persoon();
- persoon1.Voornaam = LeesString("Geef voornaam: ");
- persoon1.Achternaam = LeesString("Geef achternaam: ");
- persoon1.Leeftijd = LeesInt("Geef leeftijd: ");
- persoon1.Woonplaats = LeesString("Geef woonplaats: ");
- return persoon1;
- }
- void PrintPersoon(Persoon p)
- {
- Console.WriteLine("\n{0} {1}\n{2} {3}", p.Voornaam,p.Achternaam, p.Leeftijd, p.Woonplaats);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement