/*
* Copyright 2023, Ali Arya
* Anyone Can Code: Algorithmic Thinking
* Example 6.1c
*/

//simple program demonstrating encapsulation

#include <stdio.h>
#include <iostream>
using namespace std;


int numStudents = 0; //global variables holding the number of students
struct Student
{
    int ID;
    int Grades[20];
    int GPA;
};

Student InitStudent()
{
    Student s;
    s.ID = 1000 + numStudents;	//start from 1000
    numStudents++;
    for (int i = 0; i < 20; i++)
    {
        s.Grades[i] = -1;		//use -1 to mean not-defined-yet
    }
    s.GPA = -1;
    return s;
}
void PrintStudent(Student s)
{
    printf("ID = % d\n", s.ID);
    for (int i = 0; i < 20; i++)
    {
        printf("Grade - % d = % d\n", i, s.Grades[i]);
    }
    printf("GPA = % d\n", s.GPA);
}

int main()
{
    Student s1 = InitStudent();
    PrintStudent(s1);
    Student s2 = InitStudent();
    PrintStudent(s2);
}

