Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy of branch #20

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions src/main/java/com/stir/cscu9t4practical1/CycleEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.stir.cscu9t4practical1;

public class CycleEntry extends Entry{



private String terrain;



private String tempo;
public CycleEntry(String n, int d, int m, int y, int h, int min, int s, float dist,String terrain,String tempo) {
super(n, d, m, y, h, min, s, dist);
this.terrain = terrain;
this.tempo = tempo;
}
public String getTerrain() {
return terrain;
}

public void setTerrain(String terrain) {
this.terrain = terrain;
}
public String getTempo() {
return tempo;
}

public void setTempo(String tempo) {
this.tempo = tempo;
}
public String getEntry(){
String result = getName()+ " did a " + getTerrain() +" cycle for " +
getDistance()+ " km in at a tempo of "+ getTempo() +" for "
+getHour()+":"+getMin()+":"+ getSec() + " on "
+getDay()+"/"+getMonth()+"/"+getYear()+"\n";
return result;
}
}
19 changes: 10 additions & 9 deletions src/main/java/com/stir/cscu9t4practical1/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import java.util.Calendar;
public class Entry {
private String name;
private Calendar dateAndTime;
private float distance;

protected String name;
protected Calendar dateAndTime;
protected float distance;

public Entry (String n, int d, int m, int y, int h, int min, int s, float dist) {
name = n;
Expand All @@ -14,7 +15,7 @@ public Entry (String n, int d, int m, int y, int h, int min, int s, float dist)
dateAndTime = inst;
distance = dist;
} //constructor

public String getName () {
return name;
} //getName
Expand Down Expand Up @@ -49,10 +50,10 @@ public float getDistance () {
} //getYear

public String getEntry () {
String result = getName()+" ran " + getDistance() + " km in "
+getHour()+":"+getMin()+":"+ getSec() + " on "
+getDay()+"/"+getMonth()+"/"+getYear()+"\n";
return result;
String result = getName()+ " ran "+ getDistance() + " km in "
+getHour()+":"+getMin()+":"+ getSec() + " on "
+getDay()+"/"+getMonth()+"/"+getYear()+"\n";
return result;
} //getEntry

} // Entry
30 changes: 30 additions & 0 deletions src/main/java/com/stir/cscu9t4practical1/SprintEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.stir.cscu9t4practical1;

public class SprintEntry extends Entry{


private int repetitions;


private int recoveryIntervals;
public SprintEntry(String n, int d, int m, int y, int h, int min, int s, float dist,int repetitions,int recoveryIntervals){
super(n,d,m,y,h,min,s,dist);
this.repetitions = repetitions;
this.recoveryIntervals = recoveryIntervals;
}public int getRepetitions() {
return repetitions;
}

public int getRecovery() {
return recoveryIntervals;
}


public String getEntry(){
String result = getName()+ " Sprinted " + getRepetitions() +" repetitions of: " +
getDistance()+ " km in With breaks of "+ getRecovery() +" mins in between "
+getHour()+":"+getMin()+":"+ getSec() + " on "
+getDay()+"/"+getMonth()+"/"+getYear()+"\n";
return result;
}
}
24 changes: 24 additions & 0 deletions src/main/java/com/stir/cscu9t4practical1/SwimEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.stir.cscu9t4practical1;

public class SwimEntry extends Entry{

private String where;
public SwimEntry(String n, int d, int m, int y, int h, int min, int s, float dist,String where) {
super(n, d, m, y, h, min, s, dist);
this.where = where;
}
public String getWhere() {
return where;
}

public void setWhere(String where) {
this.where = where;
}
public String getEntry(){
String result = getName()+ " Swam " + getWhere() +" for " +
getDistance()+ " km in "
+getHour()+":"+getMin()+":"+ getSec() + " on "
+getDay()+"/"+getMonth()+"/"+getYear()+"\n";
return result;
}
}
43 changes: 42 additions & 1 deletion src/main/java/com/stir/cscu9t4practical1/TrainingRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,48 @@ public String lookupEntry (int d, int m, int y) {
}
return result;
} // lookupEntry

public String lookupAllEntries (int d, int m, int y) {
ListIterator<Entry> iter = tr.listIterator();
String result = "";
while (iter.hasNext()) {
Entry current = iter.next();
if (current.getDay()==d && current.getMonth()==m && current.getYear()==y)
result += current.getEntry();
}
return result;
}
public Boolean CheckIfEntryExists (int d, int m, int y,String name) {
ListIterator<Entry> iter = tr.listIterator();
Boolean result = false;
while (iter.hasNext()) {
Entry current = iter.next();
if (current.getDay()==d && current.getMonth()==m && current.getYear()==y && current.getName().equalsIgnoreCase(name))
result = true;
}
return result;
}
public String lookupAllEntriesByName(String searchTerm){
ListIterator<Entry> iter = tr.listIterator();
String result = "";
while (iter.hasNext()) {
Entry current = iter.next();
if (current.name.equalsIgnoreCase(searchTerm)){
result += current.getEntry();
}
}
return result;
}
public String removeAllEntries (int d, int m, int y,String n) {
ListIterator<Entry> iter = tr.listIterator();
String result = "No entries under that name and date";
while (iter.hasNext()) {
Entry current = iter.next();
if (current.getDay()==d && current.getMonth()==m && current.getYear()==y && current.getName().equalsIgnoreCase(n))
result = "Entry: "+n+ " on " +d+"/"+m+"/"+y+" was removed successfully";
iter.remove();
}
return result;
}
// Count the number of entries
public int getNumberOfEntries(){
return tr.size();
Expand Down
Loading