Commit 5f419360 authored by Gerson Sunyé's avatar Gerson Sunyé
Browse files

Exercises were moved to a separate project

parent cd67cee2
Pipeline #7206 passed with stage
in 20 seconds
group 'fr.unantes'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.0.2'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.0.3'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.0.3'
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
}
This diff is collapsed.
This diff is collapsed.
@inproceedings{Kerievsky:2004,
author = {Kerievsky, Joshua},
title = {{Refactoring to Patterns}},
booktitle = {Extreme Programming and Agile Methods - XP/Agile Universe 2004},
year = {2004},
editor = {Zannier, Carmen and Erdogmus, Hakan and Lindstrom, Lowell},
pages = {232--232},
publisher = {Springer Berlin Heidelberg},
address = {Berlin, Heidelberg}
}
<?xml version="1.0" encoding="UTF-8"?>
<viewpoint:DAnalysis xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:viewpoint="http://www.eclipse.org/sirius/1.1.0" xmi:id="_jbXMkBvmEeiPMcUWmRbk4g" version="12.1.0.201708031200"/>
public class Date {
private int day;
private int month;
private int year;
public Date (int d, int m, int y) {
assert isValidDate(d,m,y);
day = d;
month = m;
year = y;
}
/**
* Calculate day of week using Zeller's algorithm
*
* @return 0 for Saturday, 1 for Sunday, etc.
*/
public int dayOfWeek() {
assert isValid() : "Valid" ;
assert year > 1752 : "Modern"; // and not russia < 19xx ...
int hundreds = this.year / 100;
int centuryYear = this.year % 100;
int m = this.month;
int result;
// march = 3; jan = 13, feb = 14 of previous year.
if (m < 3) {
m += 12;
if (centuryYear > 0) {
centuryYear -= 1;
} else {
centuryYear = 99;
hundreds -= 1;
}
}
// Zeller formula.
result = ((this.day + ((26 * (m + 1)) / 10) +
centuryYear + (centuryYear / 4) + (hundreds / 4)
- (2 * hundreds)) % 7);
// remainder to modulo
if (result < 0) {
result = result + 7;
}
assert result >= 0 && result < 7 : "Valid result";
return result;
}
private boolean isValidDate(int d, int m, int y) {
return d >= 1 && d <= 31 &&
m >= 1 && m <= 12 &&
y > 0;
}
private boolean isValid() {
return this.isValidDate(day,month,year);
}
}
\ No newline at end of file
/**
* Created by sunye on 09/12/2016.
*/
public class Main {
public static void main(String[] args) {
System.out.println(-1 % 20);
System.out.println((double) (18/4));
Date d = new Date(21,2,2002);
System.out.println(d.dayOfWeek());
d = new Date(11,7,1932);
System.out.println(d.dayOfWeek());
d = new Date(15,2,1950);
System.out.println(d.dayOfWeek());
d = new Date(5,3,1964);
System.out.println(d.dayOfWeek());
d = new Date(2,1,2000);
System.out.println(d.dayOfWeek());
}
}
package fr.unantes.agenda;
/**
* Created on 20/02/2018.
*
* @author sunye.
*/
public class AbstractEvent {
protected String id;
protected TimeSlot slot;
public AbstractEvent(String id, TimeSlot slot) {
this.id = id;
this.slot = slot;
}
public TimeSlot slot() {
return slot;
}
}
package fr.unantes.agenda;
/**
* Created on 20/02/2018.
*
* @author sunye.
*/
public interface Event {
boolean conflictsWith(Event other);
boolean conflictsWithSingleEvent(SingleEvent other);
boolean conflictsWithRecurrentEvent(RecurrentEvent other);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment