|Programming Project 2|
First, we re going to write a function to check when two tiles are next to each other. For example,
we might want to know if one aircraft is close to a gate, another aircraft, or the runway.
We will assume that all airports are rectangular in shape. The airport is conceptually imagined as a
Obviously this is a very small airport! For this project, the width and height of the airport can change, depending on what arguments are passed into this function.
Your function should determine if the
You may assume this code will never be tested on floats that are also integers, like 1.0 or 5.0 (no need to write those test cases).
For the second function, we're going to calculate the distance between
two points on a map. A function,
You should assume that the arguments passed into this function will always be valid natural numbers of integer type.
checkNeighborand one test case of
getDistance. Each test case is two lines long: the first line contains the name of the function, followed by a space, followed by all of the arguments to the function, each separated by a single space, and terminated by a newline. Then, on the next line, you should provide the expected answer for that function call, terminated by a newline. In your tests, make sure you include spaces where they need to be, otherwise they will not diff.
tests.txtfile to something that Marmoset will understand. We have provided a file for you, called DriverBuild.class (right-mouse click and save this file into the same directory as all of your other files for this project). To use this file, from a terminal in that directory, type:
java DriverBuild tests.txt
DriverJava.javathat you will submit as your test cases for this project. Note that you do not need to know or worry about how
DriverBuild.classworks (you will be learning about Java in CS211 if you take it), except each time you type the commands above, it will overwrite any older version of
DriverJava.javain that directory. Note that this is a delicate process, and if your test cases are malformed in any way, the
DriverBuildprogram will not be able to correctly convert them to something that Marmoset understands. If you see any error messages from Marmoset regarding "compilation", this means that your test file was not properly formatted, so you need to go back, fix the format, re-run
DriverBuild, and resubmit to Marmoset. Marmoset will grade the quality of your test suite.
project2.py(and remember the link to the template for this file above). You should get started writing your python code as soon as all of you finish your test suite and it passes both the public and release tests on Marmoset -- do not wait!
debugfunction (see the two examples) that you can use just like a print statement. In the template file, you will have to choose which version of python you want, and
MARMOSETon line 7 to the value
Trueto disable debug printing. If you need to re-enable it, just reset the value to
debugfunction. When you're ready to submit to Marmoset, re-comment that line you changed (so the debug code looks like the original template), otherwise you will get the error in Piazza post 281.
10**2is equal to 100. Use 0.5 and not 1/2 in your code. You will need to derive this formula on your own; discussing it with other students (including Piazza) is considered an Honor Code violation.
[0:5]after the string (we will cover this in more detail later). For example, if
cityholds the string
city[0:5]would evaluate to the substring
in, numeric comparison operators (<,>,<=,>=),
str(x), and the
abs(x)function useful for this project. You will also have to use if-else statements. You will need the
returnstatement to get your functions to return a value - DO NOT use the
debugfunction, as described above.
driver_v3.py, that will use your
tests.txtfile and print out whether or not the tests you wrote passed or failed, on the python code you wrote. First, decide which version of python you're using; for the older version of Python, you'll want
driver_v2.py, and for the newer version of python you'll want
driver_v3.py. To use this driver, make sure your
driver_v3.pyare all in the same directory, and from a terminal in that directory, type either:
stopon a single line after the last test you want run in your
driver_vX.py. Marmoset submission should be a last and rare step! If you have any print statements in your code, Marmoset will give you a zero - use the
tests.txtabove: these tests are the Public Tests on Marmoset.
DriverJava.javafile (see above for how to convert your
tests.txtfile into this
DriverJava.javafile) on Marmoset following the link to CS112-2T. (The T stands for TEST)
project2.py. Normally, Marmoset is set up to work with Java files, which is why we have this workaround. Submit ONLY your
SystemCall.javafiles on Marmoset following the link to CS112-2C. (the C stands for CODE). Find the link on Marmoset to submit Project 2. Once you pass all the public tests, use your tokens wisely to start examining the release tests. Do not change the name of the files.