Back to project page SELP2013.
The source code is released under:
License ======= This work is licensed under the BSD 2-clause license as follows. # BSD 2-clause license Copyright (c) 2013, Sky Welch All rights reserved. Redistribution and use in source and ...
If you think the Android project SELP2013 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package uk.co.skywelch.selp2013; //from w ww .j a va 2 s . c o m import java.util.ArrayList; import java.util.HashMap; import java.util.Map; public class Lecture implements ListItem, Comparable<Lecture> { public String course; public HourMinute start; public HourMinute finish; public int semester; public String day; public ArrayList<Integer> years; public String room; public String building; public String comment; public Lecture(String course, HourMinute start, HourMinute finish, int semester, String day, ArrayList<Integer> years, String room, String building, String comment) { this.course = course; this.start = start; this.finish = finish; this.semester = semester; this.day = day; this.years = years; this.room = room; this.building = building; this.comment = comment; } @Override public String toString() { // Populate a hashmap with lecture contents for easy visual output HashMap<String, String> variables = new HashMap<String, String>(); variables.put("Start", start.toString()); variables.put("Finish", finish.toString()); variables.put("Semester", Integer.toString(semester)); variables.put("Day", day); String sYears = ""; for (Integer year : years) { sYears += Integer.toString(year) + " "; } variables.put("Years", sYears); variables.put("Room", room); variables.put("Building", building); variables.put("Comment", comment); String ret = "Lecture '" + course + "' {"; for (Map.Entry<String, String> entry : variables.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); ret += " " + key + ": '" + value + "'"; } ret += " }"; return ret; } @Override public boolean isSection() { return false; } // Returns 0 if identical, -1 if we're less than another, 1 if more than // another Sorts by hour, then minute, then course code @Override public int compareTo(Lecture l2) { int ret = 0; int l1hour = start.getHour(); int l1minute = start.getMinute(); int l2hour = l2.start.getHour(); int l2minute = l2.start.getMinute(); if (l1hour < l2hour) ret = -1; else if (l1hour > l2hour) ret = 1; else { if (l1minute < l2minute) ret = -1; else if (l1minute > l2minute) ret = 1; else { return course.compareTo(l2.course); } } return ret; } }