Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_91"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Expand Down
2 changes: 1 addition & 1 deletion .project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>butterpillar-conversions</name>
<name>butterpillar-conversions1</name>
<comment></comment>
<projects>
</projects>
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
language: java

jdk:
-oraclejdk8
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jax-ftd-day-4-java-assignment
===

[![Build Status](https://travis-ci.org/retrograzer/jax-ftd-day-4-java-assignment.svg?branch=retrograzer)](https://travis-ci.org/retrograzer/jax-ftd-day-4-java-assignment)
24 changes: 17 additions & 7 deletions src/main/java/com/cooksys/butterpillar/model/Butterpillar.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,41 @@

public class Butterpillar {

// any instance fields should be private
double length;
double leavesEaten;

public Butterpillar(double d, double e) {
leavesEaten = d;
length = e;
}

public Butterpillar() {
// TODO Auto-generated constructor stub
}

public double getLength() {
return 0; // TODO: to be implemented
return length; // TODO: to be implemented
}

public void setLength(double length) {
// TODO: to be implemented
this.length = length;
}

public double getLeavesEaten() {
return 0; // TODO: to be implemented
return leavesEaten; // TODO: to be implemented
}

public void setLeavesEaten(double leavesEaten) {
// TODO: to be implemented
this.leavesEaten = leavesEaten;
}

public boolean equals(Butterpillar b) {
return false; // TODO: to be implemented
return length == b.length && leavesEaten == b.leavesEaten;
}

@Override
public String toString() {
return null; // TODO: to be implemented
return "Butterpillar [length:" + length + ", leavesEaten: " + leavesEaten + "]";
}

@Override
Expand Down
24 changes: 17 additions & 7 deletions src/main/java/com/cooksys/butterpillar/model/Catterfly.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,41 @@

public class Catterfly {

// any instance fields should be private
double wingspan;
double weight;

public Catterfly(double d, double e) {
weight = d;
wingspan = e;
}

public Catterfly() {
// TODO Auto-generated constructor stub
}

public double getWingspan() {
return 0; // to be implemented
return wingspan; // to be implemented
}

public void setWingspan(double wingspan) {
// to be implemented
this.wingspan = wingspan;
}

public double getWeight() {
return 0; // TODO: to be implemented
return weight; // TODO: to be implemented
}

public void setWeight(double weight) {
// TODO: to be implemented
this.weight = weight;
}

public boolean equals(Catterfly c) {
return false; // TODO: to be implemented
return wingspan == c.wingspan && weight == c.weight;
}

@Override
public String toString() {
return null; // TODO: to be implemented
return "Catterpillar [wingspan:" + wingspan + ", weight: " + weight + "]";
}

@Override
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/com/cooksys/butterpillar/model/GrowthModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,40 @@

public class GrowthModel {

// any instance fields should be private
private double lengthToWingspan;
private double leavesEatenToWeight;

public double getLengthToWingspan() {
return 0; // to be implemented
return lengthToWingspan; // to be implemented
}

public void setLengthToWingspan(double lengthToWingspan) {
// to be implemented
this.lengthToWingspan = lengthToWingspan;
}

public double getLeavesEatenToWeight() {
return 0; // to be implemented
return leavesEatenToWeight; // to be implemented
}

public void setLeavesEatenToWeight(double leavesEatenToWeight) {
// to be implemented
this.leavesEatenToWeight = leavesEatenToWeight;
}

public Catterfly butterpillarToCatterfly(Butterpillar butterpillar) {
return null; // to be implemented
//double le = butterpillar.getLeavesEaten();
//double len = butterpillar.getLength();
return new Catterfly(butterpillar.leavesEaten * leavesEatenToWeight, butterpillar.length * lengthToWingspan); // to be implemented
}

public Butterpillar catterflyToButterpillar(Catterfly catterfly) {
return null; // to be implemented
//double le = catterfly.getWingspan();
//double len = catterfly.getWeight();
return new Butterpillar( catterfly.weight / leavesEatenToWeight, catterfly.wingspan / lengthToWingspan);
}

public boolean equals(GrowthModel g) {
return false; // TODO: to be implemented
return leavesEatenToWeight == g.leavesEatenToWeight && lengthToWingspan == g.lengthToWingspan;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.cooksys.butterpillar.test.model;

import static org.junit.Assert.fail;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cooksys.butterpillar.model.Butterpillar;
import com.cooksys.butterpillar.model.Catterfly;
Expand All @@ -19,6 +19,7 @@ public class GrowthModelTest {
private GrowthModel model;
private List<Butterpillar> butterpillars;
private List<Catterfly> catterflies;
public Logger log = LoggerFactory.getLogger(GrowthModelTest.class);

@Before
public void before() {
Expand Down