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

//simple program demonstrating encapsulation with classes

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


int numStudents = 0; //global variables holding the number of students
class Student
{
    int ID;
    int Grades[20];
    int GPA;
public:
    void Init()
    {
        ID = 1000 + numStudents;	//start from 1000
        numStudents++;
        for (int i = 0; i < 20; i++)
        {
            Grades[i] = -1;		//use -1 to mean not-defined-yet
        }
        GPA = -1;
    }
    void Print()
    {
        printf("ID = % d\n", ID);
        for (int i = 0; i < 20; i++)
        {
            printf("Grade - % d = % d\n", i, Grades[i]);
        }
        printf("GPA = % d\n", GPA);
    }
};

//alternative way of defining a member function
//void Student::Init()
//{
//    ID = 1000 + numStudents;	//start from 1000
//    numStudents++;
//    for (int i = 0; i < 20; i++)
//    {
//        Grades[i] = -1;		//use -1 to mean not-defined-yet
//    }
//    GPA = -1;
//}


int main()
{
    Student s1;
    s1.Init();
    s1.Print();
    Student s2;
    s2.Init();
    s2.Print();
}

