Assignment 2 [10 marks]
Deadline: 8 May 2026

* This assignment can be done in teams of 5 students or less.
* Team members must be from the same lab so the TA can discuss all of them during one lab time.
* Each team must come up with their own implementation.
* Each student in the team must understand all details of the implementation.
* The code must contain no more than 15,000 characters.
* Your code must NOT include any TAB character. Convert each TAB to 4 spaces before submitting.
* You are not allowed to copy any piece of code from the internet or from any other resource.
* You are not allowed to copy any piece of code from other students.
* You are not allowed to include any files or built-in libraries, except for the described ones.
* Your coding style must follow exactly the coding style specified in CodingStyle.pdf.
* Half the mark is dedicated to test cases and following CodingStyle.
* If you have issue regarding the assignment, contact the TA, not the doctor.
* Get your submission on a flash drive or labtop and discuss your submission with the TA during the first lab after the deadline.
* The TA will not tell you your mark. He will report his evaluation to me and I will make the final evaluation.
* You are allowed to submit after the deadline with 10% mark-deduction for each late day.

--------------------------------------------------------------------------------------

* Write a C++ code that does the following:
* You are not allowed to use any built-in functions except: <cmath>, <cstdlib>, <cstdio>, <cstring>, <iostream>.
* You are not allowed to use string class, vector, or anything from STL libraries.
* Implement base struct Shape and derived structs, simulating polymorphism without using the virtual keyword.
* Do not use the C++ inheritance or polymorphism mechanisms but simulate them as described in our lecture Lecture05_GenericProg.
* You are allowed to use some lecture code. Your code must be general.
* Write standard C++, such that the following main() works. You are not allowed to modify the main().
* Half the mark is dedicatd to test cases and following the CodingStyle.pdf file.

int main()
{
    Circle circle;
    CircleInitialize(&circle, 10); // circle with radius 10

    Rectangle rectangle;
    RectangleInitialize(&rectangle, 3, 5); // rectangle with width 3 and height 5

    Ellipse ellipse;
    EllipseInitialize(&ellipse, 10, 12); // ellipse with radius 10, 12

    Square square;
    SquareInitialize(&square, 7); // square with side-length 7

    Shape* shapes[4];
    shapes[0]=(Shape*)&circle ;
    shapes[1]=(Shape*)&rectangle ;
    shapes[2]=(Shape*)&ellipse ;
    shapes[3]=(Shape*)&square ;

    double total_area=0;

    int i;
    for(i=0;i<4;i++)
    {
        double d=GetArea(shapes[i]);
        total_area+=d;
        PrintInfo(shapes[i]); // prints (cout) the radius if circle, width and height if rectangle, ... etc
    }
    
    cout<<total_area<<endl; // check if the value is correct

    return 0;
}

--------------------------------------------------------------------------------------

To submit the code:
* Write your code in exactly one cpp text file such as myfile.cpp.
* Write your IDs and names as comments at the beginning of the code.
* Make sure that myfile.cpp contains the actual code, for example open it in Notepad (do not confuse it with cbp file).
* Encode the file using the assign_encoder tool as the following:
g++ -O3 -o assign_encoder.exe assign_encoder.cpp
assign_encoder.exe ./myfile.cpp 2 3 20101111 20102222 20113333
* The 2 in the above line is the assignment ID. The 3 in the above line is number of students.
* If you are a pre-master student, use the ID 20000000 and make sure your name exists as a comment at the beginning of the code.
* Open the resulting assign_2_20101111_20102222_20113333.bin file in a text editor.
* Make sure that the text-editor did not put any line-breaks (un-check the word-wrap option).
* Copy all the text included in the file.
* Submit the text via the following Google link, as well as your IDs. If the number of students is less than 5, put the number 00000000 in place of un-needed IDs.
https://forms.gle/7SwMizNuFqcbbwJD6
