Skip to content

Commit

Permalink
Added Period class #8, reworked Jdocs #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Schmitt-Florian committed Mar 20, 2017
1 parent 62760fd commit 5f59b76
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import java.util.GregorianCalendar;

/**
* The Exam Class represents an Object in the Exam SQL table and is usually returned by methods from the DatabaseHelper Interface
*/
public class Exam {
/**
* numeric id of the exam (unique)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import java.util.GregorianCalendar;

/**
* The Homework Class represents an Object in the Homework SQL table and is usually returned by methods from the DatabaseHelper Interface
*/
public class Homework {
/**
* numeric id of the homework (unique)
Expand Down
81 changes: 81 additions & 0 deletions app/src/main/java/schmitt_florian/schoolplanner/logic/Period.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package schmitt_florian.schoolplanner.logic;


import java.util.GregorianCalendar;

/**
* The Period Class represents an Object in the Period SQL table and is usually returned by methods from the DatabaseHelper Interface
*/
public class Period {
/**
* numeric id of the period (unique)
*/
private int id;

/**
* the {@link Subject} taught in this period
*/
private Subject subject;

/**
* the time the period starts as GregorianCalendar
*/
private GregorianCalendar startTime;
/**
* the time the period ends as GregorianCalendar
*/
private GregorianCalendar endTime;

//region c'tors

/**
* standard c'tor for Period class
*
* @param id numeric id of the period (unique)
* @param subject the {@link Subject} taught in this period
* @param startTime the time the period starts as GregorianCalendar
* @param endTime the time the period ends as GregorianCalendar
*/
public Period(int id, Subject subject, GregorianCalendar startTime, GregorianCalendar endTime) {
this.id = id;
this.subject = subject;
this.startTime = startTime;
this.endTime = endTime;
}

/**
* constructs a Period from Id as int and times as Strings,
* note, that if this c'tor is used the Year, month, dayOfMonth fields in the GregorianCalendars will be initialized with 0 value
*
* @param id numeric id of the period (unique)
* @param subject the {@link Subject} taught in this period
* @param startTime the time the period starts as String separated by '-' to look like HH-MM-SS
* @param endTime the time the period ends as String separated by '-' to look like HH-MM-SS
*/
public Period(int id, Subject subject, String startTime, String endTime) {
this.id = id;
this.startTime = getTimeFromString(startTime);
this.endTime = getTimeFromString(endTime);
}
//endregion

//region private methods

/**
* method to transfer time data as Sting to a GregorianCalendar
*
* @param source string with time information separated by '-' HH-MM-SS
* @return GregorianCalendar with time information's. Year, month, dayOfMonth = 0
*/
private GregorianCalendar getTimeFromString(String source) {
return new GregorianCalendar(0,
0,
0,
Integer.parseInt(source.split("-")[0]),
Integer.parseInt(source.split("-")[1]),
Integer.parseInt(source.split("-")[2])
);
}

//endregion
}

0 comments on commit 5f59b76

Please sign in to comment.