From 39d8cd0c884634622924d4a44a87eda42077e7e4 Mon Sep 17 00:00:00 2001 From: 041401117 <041401117@my.central.wa.edu.au> Date: Thu, 8 May 2014 14:52:56 +0800 Subject: [PATCH] Update Journey.java --- Journey.java | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Journey.java b/Journey.java index 4ddbc58..bfd76ee 100644 --- a/Journey.java +++ b/Journey.java @@ -41,3 +41,48 @@ public double getKilometers() { } } +/*By the group of Jingxian And Connie*/ + +package org.jx.test; +public class Journey { + private static final int SERVICE_KILOMETER_LIMIT = 100; + private double kilometers; + + /** + * Class constructor + */ + public Journey() { + this.kilometers = 0; + } + + /** + * Appends the distance parameter to {@link #kilometers} + * @param kilometers the distance traveled + */ + public void addKilometers(double kilometers) { + System.err.println(this.kilometers); + System.err.println(kilometers); + this.kilometers += kilometers; + } + + /** + * Calculates the total services by dividing kilometers by + * {@link #SERVICE_KILOMETER_LIMIT} and floors the value (Truncates the two + * decimal places). + * + * @return the number of services needed per + * {@link #SERVICE_KILOMETER_LIMIT} + */ + public int getTotalServices() { + return (int) Math.floor(kilometers / SERVICE_KILOMETER_LIMIT); + } + + /** + * + * @return {@link #kilometers} + */ + public double getKilometers() { + return kilometers; + } + +}