generated from kzi-nastava/dotnet-wpf-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from kzi-nastava/feat/student-model
Implementation of Student Class
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / build
|
||
|
||
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 GitHub Actions / build
|
||
{ | ||
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; | ||
} | ||
} | ||
} |