Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pieter Koopman
Personal Prof public repository
Commits
72aacd46
Commit
72aacd46
authored
Oct 08, 2019
by
Markus Klinik
Browse files
Assignment03RulesSpec: add good test case
parent
c38c71e6
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
java-feedback-rascal/src/Assignment03RulesSpec.rsc
View file @
72aacd46
...
...
@@ -11,6 +11,13 @@ import Util;
import Assignment03Rules;
test bool a03Good()
{
errors = allAssignment03Rules(loadTestProject("assignment03-geometric-example-solution"));
print(errors);
return isEmpty(errors);
}
test bool projectWithGeometricInterface()
{
return isEmpty(a03_geometric_is_comparable(loadTestProject("assignment03-good")));
...
...
java-feedback-rascal/test-data/assignment03-geometric-example-solution/.classpath
0 → 100644
View file @
72aacd46
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER"
/>
<classpathentry
kind=
"src"
path=
"src"
/>
<classpathentry
kind=
"src"
path=
"test"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.junit.JUNIT_CONTAINER/4"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
java-feedback-rascal/test-data/assignment03-geometric-example-solution/.gitignore
0 → 100644
View file @
72aacd46
bin/
build/
nbproject/private/
java-feedback-rascal/test-data/assignment03-geometric-example-solution/.project
0 → 100644
View file @
72aacd46
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
assignment03-geometric-example-solution
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.eclipse.jdt.core.javanature
</nature>
</natures>
</projectDescription>
java-feedback-rascal/test-data/assignment03-geometric-example-solution/build.xml
0 → 100644
View file @
72aacd46
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project
name=
"assignment03-geometric-example-solution"
default=
"default"
basedir=
"."
>
<description>
Builds, tests, and runs the project assignment03-geometric-example-solution.
</description>
<import
file=
"nbproject/build-impl.xml"
/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="assignment03-geometric-example-solution-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>
java-feedback-rascal/test-data/assignment03-geometric-example-solution/dist/assignment03-geometric-example-solution.jar
0 → 100644
View file @
72aacd46
File added
java-feedback-rascal/test-data/assignment03-geometric-example-solution/manifest.mf
0 → 100644
View file @
72aacd46
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
java-feedback-rascal/test-data/assignment03-geometric-example-solution/nbproject/build-impl.xml
0 → 100644
View file @
72aacd46
This diff is collapsed.
Click to expand it.
java-feedback-rascal/test-data/assignment03-geometric-example-solution/nbproject/genfiles.properties
0 → 100644
View file @
72aacd46
build.xml.data.CRC32
=
6873b6e3
build.xml.script.CRC32
=
d2d8348b
build.xml.stylesheet.CRC32
=
f85dc8f2@1.90.1.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/
build-impl.xml.data.CRC32
=
6873b6e3
nbproject/
build-impl.xml.script.CRC32
=
c7a0c4e5
nbproject/
build-impl.xml.stylesheet.CRC32
=
3a2fa800@1.90.1.48
java-feedback-rascal/test-data/assignment03-geometric-example-solution/nbproject/project.properties
0 → 100644
View file @
72aacd46
#Tue Oct 08 09:45:46 CEST 2019
run.classpath
=
${javac.classpath}
\:
${build.classes.dir}
javac.test.classpath
=
${javac.classpath}
\:
${build.classes.dir}
\:\:
${libs.junit_4.classpath}
\:
${libs.hamcrest.classpath}
excludes
=
javac.processorpath
=
${javac.classpath}
dist.javadoc.dir
=
${dist.dir}/javadoc
test.src.dir
=
${file.reference.assignment03-geometric-example-solution-test}
run.modulepath
=
${javac.modulepath}
annotation.processing.enabled
=
true
build.sysclasspath
=
ignore
debug.modulepath
=
${run.modulepath}
javac.compilerargs
=
javadoc.noindex
=
false
javadoc.private
=
false
file.reference.assignment03-geometric-example-solution-test
=
test
javadoc.author
=
false
endorsed.classpath
=
main.class
=
assignment03.Main
junit.selected.version
=
3
source.encoding
=
UTF-8
auxiliary.org-netbeans-modules-projectimport-eclipse-core.key
=
src
\=
src;src
\=
test;output
\=
bin;
javac.source
=
11
includes
=
**
javadoc.use
=
true
jar.compress
=
false
javadoc.nonavbar
=
false
annotation.processing.enabled.in.editor
=
false
javadoc.notree
=
false
annotation.processing.processors.list
=
file.reference.assignment03-geometric-example-solution-src
=
src
application.vendor
=
mkl
javac.deprecation
=
false
auxiliary.org-netbeans-modules-projectimport-eclipse-core.project
=
.
jlink.launcher
=
true
javadoc.additionalparam
=
auxiliary.org-netbeans-modules-projectimport-eclipse-core.timestamp
=
1570514623495
jlink.launcher.name
=
assignment03-geometric-example-solution
build.generated.sources.dir
=
${build.dir}/generated-sources
javadoc.splitindex
=
true
javac.processormodulepath
=
run.jvmargs
=
jlink.additionalmodules
=
javadoc.encoding
=
${source.encoding}
javac.classpath
=
mkdist.disabled
=
true
run.test.modulepath
=
${javac.test.modulepath}
build.classes.excludes
=
**/*.java,**/*.form
dist.jlink.dir
=
${dist.dir}/jlink
dist.jar
=
${dist.dir}/assignment03-geometric-example-solution.jar
build.classes.dir
=
${build.dir}/classes
debug.test.modulepath
=
${run.test.modulepath}
build.test.classes.dir
=
${build.dir}/test/classes
javadoc.windowtitle
=
build.test.results.dir
=
${build.dir}/test/results
dist.dir
=
dist
build.dir
=
build
dist.archive.excludes
=
annotation.processing.source.output
=
${build.generated.sources.dir}/ap-source-output
build.generated.dir
=
${build.dir}/generated
javadoc.version
=
false
application.title
=
assignment03-geometric-example-solution
auxiliary.org-netbeans-modules-projectimport-eclipse-core.workspace
=
/home/mkl/eclipse-workspaces/java-assignments
javac.test.modulepath
=
${javac.modulepath}
debug.test.classpath
=
${run.test.classpath}
javac.external.vm
=
true
javac.target
=
11
platform.active
=
default_platform
manifest.file
=
manifest.mf
javadoc.html5
=
false
javac.test.processorpath
=
${javac.test.classpath}
meta.inf.dir
=
${src.dir}/META-INF
run.test.classpath
=
${javac.test.classpath}
\:
${build.test.classes.dir}
dist.jlink.output
=
${dist.jlink.dir}/assignment03-geometric-example-solution
annotation.processing.run.all.processors
=
true
javac.modulepath
=
src.dir
=
${file.reference.assignment03-geometric-example-solution-src}
jlink.additionalparam
=
debug.classpath
=
${run.classpath}
java-feedback-rascal/test-data/assignment03-geometric-example-solution/nbproject/project.xml
0 → 100644
View file @
72aacd46
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://www.netbeans.org/ns/project/1"
>
<type>
org.netbeans.modules.java.j2seproject
</type>
<configuration>
<data
xmlns=
"http://www.netbeans.org/ns/j2se-project/3"
>
<name>
assignment03-geometric-example-solution
</name>
<source-roots>
<root
id=
"src.dir"
name=
"src"
/>
</source-roots>
<test-roots>
<root
id=
"test.src.dir"
name=
"test"
/>
</test-roots>
</data>
</configuration>
</project>
java-feedback-rascal/test-data/assignment03-geometric-example-solution/src/assignment03/Circle.java
0 → 100644
View file @
72aacd46
package
assignment03
;
/**
*
* @author Dylan Stoutjesdijk (s1000303)
* @author Misja Zippelius (s1019965)
*/
public
class
Circle
implements
Geometric
{
private
double
x
,
y
,
radius
;
public
Circle
(
double
x
,
double
y
,
double
radius
)
{
this
.
x
=
x
;
this
.
y
=
y
;
this
.
radius
=
radius
;
}
@Override
public
double
leftBorder
()
{
return
x
-
radius
;
}
@Override
public
double
rightBorder
()
{
return
x
+
radius
;
}
@Override
public
double
bottomBorder
()
{
return
y
-
radius
;
}
@Override
public
double
topBorder
()
{
return
y
+
radius
;
}
@Override
public
double
areaObject
()
{
return
Math
.
PI
*
radius
*
radius
;
}
@Override
public
void
moveObject
(
double
dx
,
double
dy
)
{
this
.
x
=
x
+
dx
;
this
.
y
=
y
+
dy
;
}
@Override
public
String
toString
()
{
String
dx
=
String
.
valueOf
(
x
);
String
dy
=
String
.
valueOf
(
y
);
String
dradius
=
String
.
valueOf
(
radius
);
return
"circle: x coordinate: "
+
dx
+
", y coordinate: "
+
dy
+
", radius: "
+
dradius
;
}
public
double
getArea
()
{
return
areaObject
();
}
}
java-feedback-rascal/test-data/assignment03-geometric-example-solution/src/assignment03/Geometric.java
0 → 100644
View file @
72aacd46
package
assignment03
;
/**
*
* @author Dylan Stoutjesdijk (s1000303)
* @author Misja Zippelius (s1019965)
*/
public
interface
Geometric
extends
Comparable
<
Geometric
>
{
double
leftBorder
();
double
rightBorder
();
double
bottomBorder
();
double
topBorder
();
double
areaObject
();
void
moveObject
(
double
dx
,
double
dy
);
@Override
default
int
compareTo
(
Geometric
x
)
{
if
(
this
.
areaObject
()
<
x
.
areaObject
())
{
return
-
1
;
}
if
(
this
.
areaObject
()
==
x
.
areaObject
())
{
return
0
;
}
else
{
return
1
;
}
}
}
java-feedback-rascal/test-data/assignment03-geometric-example-solution/src/assignment03/GeometricArray.java
0 → 100644
View file @
72aacd46
package
assignment03
;
import
java.util.ArrayList
;
import
java.util.Collections
;
/**
*
* @author Dylan Stoutjesdijk (s1000303)
* @author Misja Zippelius (s1019965)
*/
public
class
GeometricArray
{
private
ArrayList
<
Geometric
>
objects
;
public
GeometricArray
()
{
objects
=
new
ArrayList
<>();
}
public
void
addCircle
(
Circle
circle
)
{
objects
.
add
(
circle
);
}
public
void
addRectangle
(
Rectangle
rectangle
)
{
objects
.
add
(
rectangle
);
}
public
int
getSize
()
{
return
objects
.
size
();
}
public
Geometric
getElement
(
int
index
)
{
return
objects
.
get
(
index
);
}
public
void
move
(
int
index
,
double
dx
,
double
dy
)
{
objects
.
get
(
index
).
moveObject
(
dx
,
dy
);
}
public
void
remove
(
int
index
)
{
objects
.
remove
(
index
);
}
public
ArrayList
<
Geometric
>
getObjects
()
{
return
this
.
objects
;
}
public
void
sortByArea
()
{
Collections
.
sort
(
objects
);
}
public
void
sortByX
()
{
Xcomparator
xComp
=
new
Xcomparator
();
Collections
.
sort
(
objects
,
xComp
);
}
public
void
sortByY
()
{
Ycomparator
yComp
=
new
Ycomparator
();
Collections
.
sort
(
objects
,
yComp
);
}
}
java-feedback-rascal/test-data/assignment03-geometric-example-solution/src/assignment03/Main.java
0 → 100644
View file @
72aacd46
package
assignment03
;
import
java.util.Scanner
;
/**
*
* @author Dylan Stoutjesdijk (s1000303)
* @author Misja Zippelius (s1019965)
*/
public
class
Main
{
private
final
int
maxObjects
;
private
Scanner
scan
;
private
GeometricArray
fillObjects
;
private
double
x
,
y
,
radius
,
height
,
width
;
public
static
void
main
(
String
[]
args
)
{
new
Main
();
}
public
Main
()
{
maxObjects
=
3
;
fillObjects
=
new
GeometricArray
();
scan
=
new
Scanner
(
System
.
in
);
chosen
();
}
public
void
chosen
()
{
boolean
stop
=
false
;
while
(!
stop
)
{
instructions
();
String
choice
=
scan
.
next
();
if
(
choice
.
equals
(
"quit"
))
{
System
.
out
.
println
(
""
);
System
.
out
.
println
(
"the program has been terminated"
);
stop
=
true
;
}
else
if
(
choice
.
equals
(
"show"
))
{
doShow
();
}
else
if
(
choice
.
equals
(
"circle"
))
{
doCircle
();
}
else
if
(
choice
.
equals
(
"rectangle"
))
{
doRectangle
();
}
else
if
(
choice
.
equals
(
"move"
))
{
moveObject
();
System
.
out
.
println
(
""
);
}
else
if
(
choice
.
equals
(
"remove"
))
{
doRemove
();
}
else
if
(
choice
.
equals
(
"sort"
))
{
doMove
();
}
else
{
System
.
out
.
println
(
"Not a valid input!"
);
}
}
}
public
void
doShow
()
{
for
(
int
i
=
0
;
i
<
fillObjects
.
getSize
();
i
++)
{
System
.
out
.
println
(
fillObjects
.
getElement
(
i
).
toString
());
}
System
.
out
.
println
(
""
);
}
public
void
doRectangle
()
{
x
=
scan
.
nextDouble
();
y
=
scan
.
nextDouble
();
height
=
scan
.
nextDouble
();
width
=
scan
.
nextDouble
();
if
(
fillObjects
.
getSize
()
>=
maxObjects
)
{
System
.
out
.
println
(
"The arrayList is full"
);
System
.
out
.
println
(
""
);
}
else
{
makeRectangle
();
System
.
out
.
println
(
""
);
}
}
public
void
doCircle
()
{
x
=
scan
.
nextDouble
();
y
=
scan
.
nextDouble
();
radius
=
scan
.
nextDouble
();
if
(
fillObjects
.
getSize
()
>=
maxObjects
)
{
System
.
out
.
println
(
"The arrayList is full"
);
}
else
{
makeCircle
();
System
.
out
.
println
(
""
);
}
}
public
void
doRemove
()
{
int
index
=
scan
.
nextInt
();
if
(
index
<
fillObjects
.
getObjects
().
size
())
{
fillObjects
.
remove
(
index
);
}
else
{
System
.
out
.
println
(
"sorry, this index does not exist"
);
}
System
.
out
.
println
(
""
);
}
public
void
doMove
()
{
String
line
=
scan
.
nextLine
();
if
(
line
.
equals
(
"X"
))
{
fillObjects
.
sortByX
();
}
else
if
(
line
.
equals
(
"Y"
))
{
fillObjects
.
sortByY
();
}
else
{
fillObjects
.
sortByArea
();
}
System
.
out
.
println
(
""
);
}
public
void
instructions
()
{
System
.
out
.
println
(
"Your options are;"
);
System
.
out
.
println
(
"quit - stops the program."
);
System
.
out
.
println
(
"show - lists the geometric objects."
);
System
.
out
.
println
(
"circle x y r - adds a circle at (x,y) with radius r."
);
System
.
out
.
println
(
"rectangle x y h w - adds a rectangle at (x,y) with height h and width h."
);
System
.
out
.
println
(
"move i dx dy - moves object i over the specified distance in x and y direction."
);
System
.
out
.
println
(
"remove i -deletes object i"
);
System
.
out
.
println
(
"sort - sorts the object in the array according to criterio c (see next lines)"
);
System
.
out
.
println
(
"X: objects are sorted on their most left point from small to large"
);
System
.
out
.
println
(
"Y: objects are sorted by their bottom point from small to large"
);
System
.
out
.
println
(
"No arguments: objects are sorted on their area's from small to large"
);
System
.
out
.
println
(
"Enter your command: "
);
}
public
void
makeCircle
()
{
Circle
circle
=
new
Circle
(
x
,
y
,
radius
);
fillObjects
.
addCircle
(
circle
);
}
public
void
makeRectangle
()
{
Rectangle
rectangle
=
new
Rectangle
(
x
,
y
,
width
,
height
);
fillObjects
.
addRectangle
(
rectangle
);
}
private
void
moveObject
()
{
int
index
=
scan
.
nextInt
();
double
x
=
scan
.
nextDouble
();
double
y
=
scan
.
nextDouble
();
fillObjects
.
move
(
index
,
x
,
y
);
}
}
java-feedback-rascal/test-data/assignment03-geometric-example-solution/src/assignment03/Rectangle.java
0 → 100644
View file @
72aacd46
package
assignment03
;
/**
*
* @author Dylan Stoutjesdijk (s1000303)
* @author Misja Zippelius (s1019965)
*/
public
class
Rectangle
implements
Geometric
{
private
double
xLowerLeft
,
yLowerLeft
,
width
,
height
;
public
Rectangle
(
double
x
,
double
y
,
double
width
,
double
height
)
{
this
.
xLowerLeft
=
x
;
this
.
yLowerLeft
=
y
;
this
.
height
=
height
;
this
.
width
=
width
;
}
@Override
public
double
leftBorder
()
{
return
xLowerLeft
;
}
@Override
public
double
rightBorder
()
{