Skip to content

Commit

Permalink
Program 3
Browse files Browse the repository at this point in the history
  • Loading branch information
drninjake0702 committed Apr 26, 2023
1 parent 442ae83 commit a2d14f9
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 11 deletions.
113 changes: 104 additions & 9 deletions Coverage/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
<project name="iglooscore" default="jacocoreport" xmlns:jacoco="antlib:org.jacoco.ant">

<!-- property to allow ant to find jacoco: CHANGE THE PATH to point to yours -->
<property name="jacocodir" location="/home/jcook/tools/jacoco/lib"/>
<property name="jacocodir" location="./lib"/>
<property name="src.dir" location="src/"/>
<property name="build.dir" location="bin/"/>
<property name="result.dir" location="./target"/>
<property name="result.report.dir" location="${result.dir}/site/jacoco" />
<property name="result.exec.file" location="${result.dir}/jacoco/exec" />

<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${jacocodir}/jacocoant.jar"/>
Expand All @@ -29,16 +34,106 @@
<!-- must delete coverage data file to start afresh (otherwise coverage accumulates) -->
<fileset dir="." includes="jacoco.exec"/>
</delete>
<echo message="TEST IglooScore1: 8 9 6"/>
<java classname="IglooScore1" fork="true">
<arg value="8"/><arg value="9"/><arg value="6"/>

<!--RacingScore1 test cases-->
<echo message="TEST RacingScore1: 1 2 3"/>
<java classname="edu.nmsu.cs.scoring.RacingScore1" fork="true">
<classpath path="src"/>
<arg value="1"/><arg value="2"/><arg value="3"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<echo message="TEST RacingScore1: 3 2 1"/>
<java classname="edu.nmsu.cs.scoring.RacingScore1" fork="true">
<classpath path="src"/>
<arg value="3"/><arg value="2"/><arg value="1"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>
<echo message="TEST IglooScore2: 8 9 6"/>
<java classname="IglooScore2" fork="true">

<echo message="TEST RacingScore1: 8 9 6"/>
<java classname="edu.nmsu.cs.scoring.RacingScore1" fork="true">
<classpath path="src"/>
<arg value="8"/><arg value="9"/><arg value="6"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<echo message="TEST RacingScore1: 3 3 3"/>
<java classname="edu.nmsu.cs.scoring.RacingScore1" fork="true">
<classpath path="src"/>
<arg value="3"/><arg value="3"/><arg value="3"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<echo message="TEST RacingScore1: 1 2"/>
<java classname="edu.nmsu.cs.scoring.RacingScore1" fork="true">
<classpath path="src"/>
<arg value="1"/><arg value="2"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<echo message="TEST RacingScore1: 1 2 a"/>
<java classname="edu.nmsu.cs.scoring.RacingScore1" fork="true">
<classpath path="src"/>
<arg value="1"/><arg value="2"/><arg value="a"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<!--RacingScore2 test cases-->
<echo message="TEST RacingScore2: 1 2 3"/>
<java classname="edu.nmsu.cs.scoring.RacingScore2" fork="true">
<classpath path="src"/>
<arg value="1"/><arg value="2"/><arg value="3"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<echo message="TEST RacingScore2: 3 2 1"/>
<java classname="edu.nmsu.cs.scoring.RacingScore2" fork="true">
<classpath path="src"/>
<arg value="3"/><arg value="2"/><arg value="1"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<echo message="TEST RacingScore2: 3 1 2"/>
<java classname="edu.nmsu.cs.scoring.RacingScore2" fork="true">
<classpath path="src"/>
<arg value="3"/><arg value="1"/><arg value="2"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<echo message="TEST RacingScore2: 3 3 3"/>
<java classname="edu.nmsu.cs.scoring.RacingScore2" fork="true">
<classpath path="src"/>
<arg value="3"/><arg value="3"/><arg value="3"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<echo message="TEST RacingScore2: 1 2"/>
<java classname="edu.nmsu.cs.scoring.RacingScore2" fork="true">
<classpath path="src"/>
<arg value="1"/><arg value="2"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<echo message="TEST RacingScore2: 1 2 a"/>
<java classname="edu.nmsu.cs.scoring.RacingScore2" fork="true">
<classpath path="src"/>
<arg value="1"/><arg value="2"/><arg value="a"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<echo message="TEST RacingScore2: -1, 2, 3"/>
<java classname="edu.nmsu.cs.scoring.RacingScore2" fork="true">
<classpath path="src"/>
<arg value="-1"/><arg value="2"/><arg value="3"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>

<echo message="TEST RacingScore2: 1 2 53"/>
<java classname="edu.nmsu.cs.scoring.RacingScore2" fork="true">
<classpath path="src"/>
<arg value="1"/><arg value="2"/><arg value="53"/>
<jvmarg line="-javaagent:${jacocodir}/jacocoagent.jar"/>
</java>
</target>

<!-- tests if new jacoco report needs generated by checking if top report file
Expand All @@ -53,12 +148,12 @@
<executiondata>
<file file="jacoco.exec"/>
</executiondata>
<structure name="iglooscore">
<structure name="racingscore">
<classfiles>
<fileset dir="."/>
<fileset dir="src/edu/nmsu/cs/scoring"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="."/>
<fileset dir="src/edu/nmsu/cs/scoring"/>
</sourcefiles>
</structure>
<html destdir="report"/>
Expand Down
4 changes: 3 additions & 1 deletion Coverage/src/edu/nmsu/cs/scoring/RacingScore1.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void recordScores(int s1, int s2, int s3)
public int overallScore()
{
int s;
if (score1 < score2)
if (score1 > score2) //Updated to accept the smaller of the values between score1 and score2. Originally took the larger
s = score2;
else
s = score1;
Expand Down Expand Up @@ -72,3 +72,5 @@ public static void main(String args[])
}

} // end class
// I spotted an error in overallScore where in the first if statement, it was accidentally built to take the greater of score1 and score2 as s.
// s needs to be the smallest of the scores, so this has been updated.
5 changes: 4 additions & 1 deletion Coverage/src/edu/nmsu/cs/scoring/RacingScore2.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public int overallScore()
else if (score2 < score1 && score2 < score3)
{
s1 = score1;
s2 = score2;
s2 = score3; // Updated to include score3 instead of score2 if score3 is higher
}
else if (score3 < score1 && score3 < score2)
{
Expand Down Expand Up @@ -91,3 +91,6 @@ public static void main(String args[])
}

} // end class

// The only error I spotted was in overallScore, which would incorrectly calculate the value with score1 and score2 if score2 was the lowest of the three values.
// It has been fixed.
Empty file removed SimpleWebServer/www
Empty file.
Binary file added SimpleWebServer/www/favicon.ico
Binary file not shown.
12 changes: 12 additions & 0 deletions SimpleWebServer/www/hello.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>
<head>
<title>Silly Little Guy</title>
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<p>Hello world, the current date is: <CS371date>. The server is: <CS371server>.</p>
<img src="leonardo_conservative.png" height="70px" width="70px">
<img src="mario_centrist.gif" height="70px" width="70px">
<img src="sonic_liberal.jpg" height="70px" width="70px">
</body>
</html>
Binary file added SimpleWebServer/www/leonardo_conservative.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SimpleWebServer/www/mario_centrist.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SimpleWebServer/www/sonic_liberal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a2d14f9

Please sign in to comment.