unit uResearchPaper;

interface
  uses SysUtils;
  //Q3.1 - 3
  //class header correct
  type TResearchPaper = class
    private
      //all properties named and typed correctly
       title, department, reqCode, studentID : string;
       meetDeptRequirements : boolean;
    public
      //Q3.2 - 3
      //constant declared with final/constant
      //named and typed correctly
      //assigned correctly
      const
        DEAN_MIN_PAGES = 200;

        constructor Create(inTE : string; inDT:string; inMDR:boolean; inRC:string ; inSID:string);
        function getTitle() : string;
        function getDepartment() : string;
        function getMeetsDeptRequirements() : boolean;
        function getReqCode() : string;
        function getStudentID() : string;
        function onDeansList() : boolean;
        function toString() : string;
  end;

implementation

{ TResearchPaper }

//Q3.3 - 4
//header correct
//parameter named correctly
//typed correctly
constructor TResearchPaper.Create(inTE : string ; inDT : string ; inMDR : boolean ; inRC : string; inSID: string  );
begin
 //properties assigned correctly
  title:=inTE;
  department := inDT;
  meetDeptRequirements := inMDR;
  reqCode:= inRC;
  studentID := inSID;
end;

//Q3.4 - 2
//correct header and return types for all four getters

function TResearchPaper.getDepartment: string;
begin
  Result := department;
end;

function  TResearchPaper.getMeetsDeptRequirements: boolean;
begin
  Result := meetDeptRequirements;
end;

function TResearchPaper.getReqCode: string;
begin
  Result:= reqCode;
end;

function TResearchPaper.getStudentID: string;
begin
  Result := studentID;
end;

function TResearchPaper.getTitle: string;
begin
  Result:= title;
end;


//Q6 - 7
//header correct
function TResearchPaper.onDeansList: boolean;
var
  peerReviewed, fieldResearch : boolean;
  pages : integer;
begin
   //extract pages, peer reviewed and fieldResearch

  pages := StrToInt(Copy(reqCode,1,reqCode.Length-2));
  peerReviewed := CompareText( Copy(reqCode, reqCode.Length-1,1)  , 'T') = 0;
  fieldResearch :=  CompareText( Copy(reqCode, reqCode.Length,1)  , 'T') = 0;
  //includes method call to meetsDeptRequirements
  //makes use of the constant
  Result:= getMeetsDeptRequirements() AND  (pages >= DEAN_MIN_PAGES) AND peerReviewed AND fieldResearch;
end;

//Q3.5  - 5
//header correct
function TResearchPaper.toString: string;
begin

  //all fields included
  //format correct
  Result:=  'Title: ' + title + #13#10;
  Result := Result + 'Author: ' + studentID + #13#10;
  Result := Result + 'Meets ' + department + '''s requirements: ';
  //calling the method
  //correctly returned
  if getMeetsDeptRequirements() then
    Result:= Result + ' true' +  #13#10
  else
     Result:= Result + ' false' +  #13#10;


end;

end.
