Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CS538: Assignment #4 - Java, C#, Pizza, Python CS538: Spring 2008 Assignment #4: Java, C#, Pizza, Python Handin procedure Your handin folder is in ~cs538-1/public/handin/proj4/login where login is your login name. Note that you can solve any or all (or none) of the questions in Project #4. Each question is worth 25 points, totaling to a maximum of 100 points for all four parts. Put your solution(s) in a SEPARATE FILE for each part: 1,2, 3, 4. You can also include a file called README with any notes about your submission. Make each file SELF-CONTAINED. Each file should be able to compile and execute on its own, independent of other files, and without assuming that we will supply any definitions or code. Don't assume that your code will execute in the handin folder. Here's the complete list of definitions that need to be present in each file. Note that these are just the minimum definitions required in each file. Please make sure that your code behaves as shown. A note about the printN function: it should print the members of a lazy list separated by spaces and terminated by a newline. So the list "1,2,3,4" should print as "1 2 3 4" (on a separate line). The null list should print as a blank line. Extra spaces and tabs are fine, just make sure that all list elements are separated by white space and on the same line. Also note that there is no requirement of a specific exception to be raised by function Nth, any reasonable one will do, even a user-defined one. Our tests will catch whatever exception you raise. Question Required definitions 1,2 class LazyList { ... } //As defined in handout abstract class LazyListFct { ... } //As defined in handout also, any subclasses of LazyListFct required by your code. 3 class LazyList { ... } (with T as the type of the list element, and with the same defined member functions as the Java class LazyList) 4 Define the following functions: seq(first,last) infseq(start) firstN(lazylist,n) (return an ordinary list) Nth(lazylist,n) (return a value or raise an exception) filter(control_lazylist,data_lazylist) primes() Here, all lazylists are to be represented using a list as specified in the handout. Null lists are represented by the empty list [], lists of one element are represented by the singleton list [val], and longer lists by a 2-element list [val,fct] where fct is a function that can be called to yield the rest of the lazy list. Your submission must work correctly with the Java, Pizza and Python interpreters installed in CS. We'll probably use MS Visual Studio to test C# solutions. See the Language Links page for more information on each language. Also see the Language Tips section below for additional help on Pizza. You are free to work with your own version of these languages which you might have downloaded and installed at home, but before submission, you must make sure your code runs with the CS interpreters. If you use library functions, please make sure that these libraries are also available in the CS installations. You can assume that your code will always be passed valid input of the right type, so you do not need to check, for example, that the input argument is a list or a number and so on. But your functions should be able to correctly handle all valid input, including boundary conditions such as empty lists. Grading criteria The first and foremost criteria for grading is correctness. Your programs should execute without errors and produce the correct output with our test suite. Points are awarded for each test input successfully handled by your code. You can use any algorithms or language features or libraries to produce the correct output, you are not restricted to following the exact path set by the questions. No extra points for the most elegant programs but you are encouraged to write in a style natural to the language you use: classes and inheritance in Java and C#, parametric polymorphism and first-class functions in Pizza, and clasess, lists and lambdas in Python. These will invariably reward you with compact, natural-looking code which is easy to read and understand. Partial credit will be given for programs that seem to be on the right track. Language Tips Check out the Language Links page for information on each language. Additional Notes on Pizza: If you're having problems running Pizza, try this in the shell: setenv CLASSPATH .:/u/f/i/fischer/public/pizza/classes:/s/jdk1.0.2/lib/classes.zip alias pc 'java -ms8m pizza.compiler.Main' You can compile and run the code with: pc LazyList.pizza pc Test.java java Test If you're running plain Java programs in addition to Pizza, we suggest clearing your CLASSPATH: setenv CLASSPATH . javac LazyList.java javac Test.java java Test Additional Notes on C#: A free copy of MS Visual Studio Express Edition for C# may be downloaded from: http://www.microsoft.com/express/download/default.aspx The Mono project provides multi-platform implementations of a C# compiler. Downloads are at: http://www.mono-project.com/Downloads