Skip to content

Commit

Permalink
[Refactor]: ExamSlot is no longer dependent on a specific course inst…
Browse files Browse the repository at this point in the history
…ance
  • Loading branch information
natasakasikovic committed Apr 28, 2024
1 parent 9ca1f91 commit 47999ef
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 82 deletions.
114 changes: 32 additions & 82 deletions LangLang/Core/Model/ExamSlot.cs
Original file line number Diff line number Diff line change
@@ -1,104 +1,54 @@
using LangLang.Core.Repository.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LangLang.Core.Model
{
public class ExamSlot: ISerializable
public class ExamSlot: ISerializable, Overlapable
{
// Private attributes
private int _id;
private int _courseId;
private int _maxStudents;
private DateTime _examDateTime;
private int _numberOfStudents;
public int Id { get; set; }
public string Language { get; set; }
public LanguageLevel Level { get; set; }

public int TutorId { get; set; }

// Public properties
public int Id
{
get { return _id; }
set { _id = value; }
}
public TimeSlot TimeSlot { get; set; }
public int MaxStudents { get; set; }

public int CourseId
{
get { return _courseId; }
set { _courseId = value; }
}
// NOTE: if possible don't save number of registeredStudents, ask the database. If not, then add attribute.


public int MaxStudents
public ExamSlot(int id, string language, LanguageLevel level, TimeSlot timeSlot, int maxStudents, int tutorId)
{
get { return _maxStudents; }
set { _maxStudents = value; }
}

public DateTime ExamDateTime
{
get { return _examDateTime; }
set { _examDateTime = value; }
}

public int NumberOfStudents
{
get { return _numberOfStudents; }
set { _numberOfStudents = value; }
}

// Constructor
public ExamSlot(int id, int courseId, int maxStudents, DateTime examDateTime, int numberOfStudents)
{
_id = id;
_courseId = courseId;
_maxStudents = maxStudents;
_examDateTime = examDateTime;
_numberOfStudents = numberOfStudents;
}

public ExamSlot(int id, int courseId, int maxStudents, DateTime examDateTime)
{
_id = id;
_courseId = courseId;
_maxStudents = maxStudents;
_examDateTime = examDateTime;
_numberOfStudents = 0;
Id = id;
Language = language;
Level = Level;
TutorId = tutorId;
TimeSlot = timeSlot;
MaxStudents = maxStudents;
}

public ExamSlot() { }

// Methods

// Method to display information about the exam slot
public override string ToString()
{
return $"ID: {_id} | Course: {_courseId.ToString()} | Max Students: {_maxStudents} | Exam Date and Time: {_examDateTime} | Number of Students: {_numberOfStudents}";
}

// Method to convert object to CSV format
//returns array of strings representing attributes of ExamSlot object in string form
public string[] ToCSV()
{
string[] csvValues =
{
_id.ToString(),
_courseId.ToString(),
_maxStudents.ToString(),
_examDateTime.ToString(),
_numberOfStudents.ToString()
};
return csvValues;
return new string[] {
Id.ToString(),
Language,
Level.ToString(),
TutorId.ToString(),
// TODO: add serialization for timeSlot when implemented
MaxStudents.ToString(),
};
}
// Method to make object from CSV data
//takes array of strings representing ExamSlot object values and sets attributes of object to that values

public void FromCSV(string[] values)
{
_id = int.Parse(values[0]);
_courseId = int.Parse(values[1]);
_maxStudents = int.Parse(values[2]);
_examDateTime = DateTime.Parse(values[3]);
_numberOfStudents = int.Parse(values[4]);
Id = int.Parse(values[0]);
Language = values[1];
Level = (LanguageLevel)Enum.Parse(typeof(LanguageLevel), values[2]);
TutorId = int.Parse(values[3]);
// TODO: add deserialization for timeSlot when implemented
MaxStudents = int.Parse(values[6]);
}
}
}
8 changes: 8 additions & 0 deletions LangLang/Core/Model/Overlapable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

namespace LangLang.Core.Model
{
public interface Overlapable
{
// TODO: implement
}
}
26 changes: 26 additions & 0 deletions LangLang/Core/Model/TimeSlot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Runtime.Serialization;

namespace LangLang.Core.Model
{
public class TimeSlot
{
// NOTE: Adapt as needed during implementation
public int Duration { get; set; }
public DateTime time { get; set; }

public bool OverlappsWith(TimeSlot timeSlot)
{
// TODO: Implement
return false;
}

public bool IsInFuture()
{
// TODO: Implement
return false;
}

// TODO: Add serialization methods
}
}

0 comments on commit 47999ef

Please sign in to comment.