Skip to content

Commit

Permalink
Merge pull request #32 from kzi-nastava/feat/student-model
Browse files Browse the repository at this point in the history
Implementation of Student Class
  • Loading branch information
natasakasikovic authored Mar 29, 2024
2 parents 79b8a4a + 100ca3c commit ea196b9
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions LangLang/Core/Model/Student.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using LangLang.Core.Repository.Serialization;
using System;

namespace LangLang.Core.Model
{
class Student : ISerializable
{

private Profile _profile;
private string _professionalQualification;
private bool _canModifyInfo; // NOTE: This attribute may not be necessary.

public Profile Profile
{
get { return _profile; }
set { _profile = value; }
}

public string ProfessionalQualification
{
get { return _professionalQualification; }
set { _professionalQualification = value; }
}

public bool CanModifyInfo
{
get { return _canModifyInfo; }
set { _canModifyInfo = value; }
}
public Student() { }

Check warning on line 30 in LangLang/Core/Model/Student.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_profile' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 30 in LangLang/Core/Model/Student.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_professionalQualification' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

public Student(string name, string lastName, UserGender gender, DateTime dateOfBirth, string phoneNumber, string email, string password, UserType role, string professionalQualification)

Check warning on line 32 in LangLang/Core/Model/Student.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_profile' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 32 in LangLang/Core/Model/Student.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_professionalQualification' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
{
Profile = new Profile(name, lastName, gender, dateOfBirth, phoneNumber, email, password, role);
ProfessionalQualification = professionalQualification;
CanModifyInfo = true;
}

public void FromCSV(string[] values)
{
Profile = new Profile(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]);

ProfessionalQualification = values[8];

if (!bool.TryParse(values[9], out bool canModifyInfo))
{
throw new FormatException("CanModifyInfo token is not in the correct format.");
}

CanModifyInfo = canModifyInfo;
}

public string[] ToCSV()
{
string[] csvValues =
{
Profile.ToString(),
ProfessionalQualification,
CanModifyInfo.ToString()
};

return csvValues;
}
}
}

0 comments on commit ea196b9

Please sign in to comment.