public static string policyPath = "policyID.txt";                                                               //the path for the text file where the policy id is saved after the program is closed and opened again the id would be read and initialised again

        public Policy(string startDate, string[] name, string[] occupation, DateTime[] dateOfBirth, double premiumCost) //the constructor which creates an object when the user tries to create a policy
        {
            if (!File.Exists(policyPath))                                                                               //checks if the policy.txt file exist
            {
                StreamWriter writePolicyID = new StreamWriter(policyPath);
                writePolicyID.Write(policyID);//writes the int variable policy ID into a text file
                writePolicyID.Close();
            }
            else
            {
                using (StreamReader readPolicyID = new StreamReader(policyPath))
                {
                    policyID = Convert.ToInt32(readPolicyID.ReadLine());//if policy id text file exists then the id is read from the file and initialised to policyID int variable
                }
            }

            policyID++;                                                                                                                                             //the policy id is incremented before a new policy is written to a csv file

            int arrayIndex = 0;                                                                                                                                     //array index is set to 0 to be used to write details from the arrays that are passed from form1.cs

            for (int count = 0; count < name.Length; count++)                                                                                                       //for loop runs as long as count is less than the length of the name string array which is 5
            {
                if (name[arrayIndex] != null)                                                                                                                       //if statement checks if the name string array at arrayIndex is not null or has a string value inside like a name of driver
                {
                    ReadAndWriteCSV.writeDetails(startDate, name[arrayIndex], occupation[arrayIndex], dateOfBirth[arrayIndex].ToString("dd/MM/yyyy"), premiumCost); //write details method is called
                    //method takes the start date of policy, drivers name, drivers occupation, drivers date of birth, and the cost of premium for the policy
                    //All of this information is printed into a csv file
                }
                arrayIndex++;//arrayIndex is incremented by 1 so when the for loop runs a second time it will look at the 2nd element in an array to check if it’s not null
            }
        }
        private void txtSaveChanges_Click(object sender, EventArgs e)
        {
            //when the button is clicked the writeDGVDetails to CSV method is called from the ReadAndWriteCSV class to write the data that is displayed in the data grid view to the csv file
            ReadAndWriteCSV.writeDGVDetails(csvDataGrid, Policy.csvPath);

            MessageBox.Show("Changes have been saved");//when it finished the message box appears telling the user that the changes have been saved
        }
        private void btnAdminSection_Click(object sender, EventArgs e)
        {
            //clicking the admin section makes the data grid view appear and the form for inputting policies and drivers disappear
            panel1.Visible      = false;
            panel2.Visible      = true;
            csvDataGrid.Visible = true;

            csvDataGrid.DataSource = ReadAndWriteCSV.readCSV(csvDataTable);
            this.Controls.Add(csvDataGrid);
        }