using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TP03Ex1_TarifVoyage
{
    public partial class Form1 : Form
    {
        //1 - Déclaration variables
        double tarif;
        int age;
        double prix;
        int nbpers;
        double cumul;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //2 - Initialisations et affichages écran

            txttarif.Text = "100";
            cumul = 0;
            nbpers = 0;
            lblnbpers.Text = Convert.ToString(nbpers);
            lblcumul.Text = Convert.ToString(cumul);

        }

        private void btnValider_Click(object sender, EventArgs e)
        {   
            //3 - Récupération saisie utilisateur
            tarif=Convert.ToDouble(txttarif.Text);
            age = Convert.ToInt32(txtage.Text);
            //4 - Traitements calculs
            
            nbpers = nbpers + 1;
            if (age < 18)
            {
                tarif = (tarif * 0.5);
            }
            else
            {
                tarif = (tarif * 1);
            }
            cumul = (cumul + tarif);
            //5 - Affichages écran
            lblnbpers.Text=Convert.ToString(nbpers);
            lblprix.Text= Convert.ToString(tarif);
            lblcumul.Text= Convert.ToString(cumul); 

        }
    }
}
