using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ch10_3
{
    class randomAccessRecord
    {
        private const int MAX_LEN_ARRAY = 20;
        private const int SIZE_CHAR = 2;
        private const int SIZE_INT32 = 4;
        private const int SIZE_DOUBLE = 8;
        public const int SIZE = SIZE_INT32 + 2 * (SIZE_CHAR * MAX_LEN_ARRAY) + SIZE_DOUBLE;

        private int stNo;
        private char[] FName = new char[MAX_LEN_ARRAY];
        private char[] LName = new char[MAX_LEN_ARRAY];
        private double grade;
        public randomAccessRecord()
        {
            stNo = 0;
            FName = "".ToCharArray();
            LName = "".ToCharArray();
            grade = 0;
        }
        public randomAccessRecord(int stNoValue, string FNameValue, string LNameValue, double gradeValue)
        {
            stNo = stNoValue;
            FName = FNameValue.ToCharArray();
            LName = LNameValue.ToCharArray();
            grade = gradeValue;
        }
        public int StNo
        {
            get
            {
                return stNo;
            }
            set
            {
                stNo = value;
            }
        }
        public string fName
        {
            get
            {
                return new string(FName);
            }
            set
            {
                int size = value.Length;
                string fNameString = value;
                if (MAX_LEN_ARRAY >= size)
                    fNameString = value + new string(' ', MAX_LEN_ARRAY - size);

                else
                    fNameString = value.Substring(0, MAX_LEN_ARRAY);
                FName = fNameString.ToCharArray();
            }
        }
        public string lName
        {
            get
            {
                return new string(LName);
            }
            set
            {
                int size = value.Length;
                string lNameString = value;
                if (MAX_LEN_ARRAY >= size)
                    lNameString = value + new string(' ', MAX_LEN_ARRAY - size);

                else
                    lNameString = value.Substring(0, MAX_LEN_ARRAY);
                LName = lNameString.ToCharArray();
            }
        }
        public double Grade
        {
            get
            {
                return grade;
            }
            set
            {
                grade = value;
            }
        }
    }
}
