Commit a6bbabf6 authored by michael lundquist's avatar michael lundquist
Browse files

first commit with the assignment.

parents
Pipeline #4174 failed with stages
in 46 seconds
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
[*.yml]
indent_size = 2
[*.sh]
end_of_line = lf
# When shell scripts end in CRLF, bash gives a cryptic error message
*.sh text eol=lf
#
# Standard Maven .gitignore
#
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
#
# IntelliJ
#
*.iml
.idea/*
!.idea/runConfigurations/
#
# Visual Studio Code
#
.settings/
.classpath
.project
.vscode/
before_script:
- apt-get -qq update
- apt-get -qq upgrade
- export BUILD_DIR=$PWD
- apt-get -qq install default-jre
- apt-get -qq install default-jdk
- java -version
- update-alternatives --config java
- apt-get -qq install wget
- cd /opt
- wget ftp://mirror.reverse.net/pub/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz
- tar xvf apache-maven-3.6.0-bin.tar.gz
- export M2_HOME=/opt/apache-maven-3.6.0
- export M2=$M2_HOME/bin
- export PATH=$M2:$PATH
- cd $BUILD_DIR/thirdlab
- mvn -version
maven_build:
script: mvn verify
\ No newline at end of file
language: java
jdk: oraclejdk8
after_success:
- mvn coveralls:report
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ds.thirdlab</groupId>
<artifactId>thirdlab</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.10</version>
</dependency>
<dependency>
<groupId>com.github.ngeor</groupId>
<artifactId>checkstyle-rules</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<configuration>
<configLocation>com/github/ngeor/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<!--
You can run jacoco in the default profile with:
mvn jacoco:prepare-agent test jacoco:report
-->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>com/github/ngeor/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
<profiles>
<!--
This profile enables jacoco when unit tests are run.
You can run it with mvn -P jacoco test.
It also activates itself on Travis.
-->
<profile>
<id>jacoco</id>
<activation>
<property>
<name>env.TRAVIS</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<phase>validate</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!--
For the Travis profile:
- we want to break the build on any checkstyle violation.
- we want to be able to publish coverage report to coveralls.
-->
<profile>
<id>travis</id>
<activation>
<property>
<name>env.TRAVIS</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
package com.ds.thirdlab;
/**
* Hello world!
*/
public final class App {
private App() {
}
/**
* Says hello to the world.
* @param args The arguments of the program.
*/
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
package com.ds.thirdlab;
public class Flight {
private String flightNumber;
private boolean connectingFlight;
private long connectionPeriod;
public Flight(String flightNumber, boolean connectingFlight){
this.flightNumber = flightNumber;
this.connectingFlight = connectingFlight;
}
public boolean setConnectionPeriod(long p){
if (p < PQEntry.DEFAULT_KEY) {
connectionPeriod = p;
return true;
}
else return false;
}
public long getConnectionPeriod() { return connectionPeriod; }
public String getFlightNumber() {
return flightNumber;
}
public void setFlightNumber(String flightNumber) {
this.flightNumber = flightNumber;
}
public boolean isConnectingFlight() {
return connectingFlight;
}
public void setConnectingFlight(boolean connectingFlight) {
this.connectingFlight = connectingFlight;
}
public String toString (){
return "F#"+flightNumber;
}
}
\ No newline at end of file
package com.ds.thirdlab;
public class PQEntry {
private long key;
private Flight val;
public static final long DEFAULT_KEY = 1000000; //Indicates a very low priority --used for non-connective flights.
public PQEntry() {}
public void setValue(Flight p){
val = p;
calcKey();
}
private void calcKey(){
//TODO part
}
public Flight getValue() {return val; }
public long getKey(){
return key;
}
public String toString() {
return "Value: "+ val.toString() + ", key: "+ key;
}
}
\ No newline at end of file
package com.ds.thirdlab;
import java.util.*;
public class UnsortedPriorityQueue {
private LinkedList<PQEntry> queue;
public UnsortedPriorityQueue(){
queue = new LinkedList<PQEntry>();
}
public void add(Flight p){
PQEntry entry = new PQEntry();
entry.setValue(p);
queue.add(entry);
}
public PQEntry removeMin(){
if(queue.isEmpty()){
System.out.println("The queue is empty.");
return null;
}
else{
int min = 0;
for(int i= 1; i<queue.size(); i++){
if(queue.get(min).getKey() > queue.get(i).getKey())
min =i;
else if(queue.get(min).getKey() == queue.get(i).getKey()){
if(min>i) min = i;
}
}
PQEntry minEntry = queue.get(min);
queue.remove(min);
return minEntry;
}
}
public boolean isEmpty(){
return queue.isEmpty();
}
public int size(){
return queue.size();
}
}
\ No newline at end of file
package com.ds.thirdlab;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Unit test for simple App.
*/
public class AppTest {
/**
* Rigorous Test.
*/
@Test
public void testApp() {
assertTrue(true);
}
}
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