Java程序辅导

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

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Programming Assignment #2 CSCI.4430/6969 Programming Languages Spring 2005 Programming Assignment #2 This assignment is to be done either individually or in groups of two or three students. Do not show your code to any other group and do not look at any other group's code. Do not put your code in a public directory or otherwise make it public. However, you may get all the help you need from the TAs or the instructor. You are encouraged to use the WebCT Discussions page to post problems so that other students can also answer/see the answers. MIJava:  Multiple inheritance extension to Java. The goal of this assignment is to implement a limited multiple inheritance extension to a subset of Java (see VRH sections 7.4.4 and 7.4.5 and also see FWH exercises 5.31 and 5.32) using OpenJava. Following is an example skeleton of a program TA.oj in MIJava:     public class TA instantiates MIJava multiextends Student, Staff {         ...   } This TA class extends both the Student and Staff classes.  The code for a sub-class should be able to access information in any of its super-classes.  For example, the Student class may have a getGPA() method which does not apply to Staff objects, and the Staff class may have a getSalary() method which does not apply to Student objects.  However, getGPA() and getSalary() are both valid methods for an instance of the TA class. Part 1. Simulate multiple inheritance using single inheritance. In this part of the assignment, you are to write Java code that simulates the MIJava code for a given example (e.g., TA code above). Since Java does not directly support multiple class inheritance, you are to come up with a strategy to simulate multiple inheritance using single class inheritance.  You may for example use Java's support for multiple interface inheritance. You need to decide what to do with duplicate method and field names.  Specify your language extension restrictions clearly:  what is allowed and what is not, and what is your conflict resolution methodology. Part 2. Automatically generate Java code for MIJava. In this part of the assignment, you are to write OpenJava code that automates the translation of MIJava programs into Java programs.  Your OpenJava meta-class should take MIJava code such as TA.oj and produce the corresponding Java code implementing your multiple inheritance semantics.  The generated code should generally resemble the code you produced in Part 1.  Specify any restrictions and assumptions you make in the process. Examples Example files can downloaded here. They demonstrate what your strategy for multiple inheritance must handle. These examples will be used to grade your assignment, so if your strategy requires changes to these files due to new syntax, please modify the files as required and upload them along with your project. There are eight different example folders, each containing a set of classes. What they test is as follows (for more detail read comments in the files). A rundown of what the different examples are is as follows: example1: trivial tests to make sure your strategy works with single inheritance and no inheritance. example2: tests conflicts between inherited fields and methods. example3: tests correctly inheriting fields and methods. example4: a more complex test of inheriting fields and methods. fields and methods are inherited not only from inherited classes, but their superclasses as well. example5: a more complex test of conflicts between fields and methods. fields and methods not only conflict with inherited classes, but their superclasses as well. example6: tests overriding methods. example7: tests passing classes with multiple inheritance as arguments to methods. example8 (bonus): tests modifying access control of inherited methods and fields. Hints Feel free to limit Java's syntax and semantics, so that you need not worry about arbitrary MIJava programs.  These assumptions may facilitate your translation process, so that you can concentrate on the issues that arise implementing multiple inheritance.  For example, it is reasonable to assume that the MIJava code: Provides no access control.  This is to say, every declared class, field, and method is public. Does not use traditional Java interfaces, only classes.  For example, to avoid collisions with generated code. Does not use both extends and multiextends clauses. Provides a constructor with no arguments, if you need one and do not want to generate it. See the Java Language Specification for learning how to access super-class fields and methods.  In particular, see: Section JLS 15.11.2 Accessing Superclass Members using super. Section JLS 15.12.4.9  Method Invocation using super. To use OpenJava on the computer science machines, first log in then use your favorite editor to open a file called ".bashrc" (it is hidden). Then add "/projects/proglang/OpenJava_1.1/src" to the CLASSPATH variable in this file, and add the line "alias ojc="/projects/proglang/OpenJava_1.1/bin/ojc.ksh". Log out and log back in and you should be able to use the open java compiler with "ojc". Due Date:   Received Time Grade Modification before Monday, April 4th, 11:59PM +10% Tuesday, April 5th, from 12:00AM to 11:59PM no modification (on time) Wednesday, April 6th, from 12:00AM to 11:59PM -10% from Thursday, April 7th, 12:00AM to  Friday, April 8th, 11:55PM -25% after Saturday, April 8th, 12:00AM not accepted Grading: The programs will be tested on the CS network versions of Java/OpenJava. The assignment will be graded mostly on correctness, but code clarity / readability will also be a factor (comment, comment, comment!).  In particular, make sure you state up front in the README file, the restrictions and assumptions you are making on your input MIJava programs.  See the professor or TAs, if you have ideas for other extensions for this assignment and would like extra credit for implementing them. Since there have been many questions about the grading, here are more specific criteria about what is expected and how your assignment will be graded. Part 1: Example Code (25%) Include example hand-written java code which which corresponds to OpenJava code using the multiextends keyword. For example, take example2, example3, example6 and example7 and write java code which will run with the desired behavior. Write-up (25%) Provide a writeup illustrating a general strategy for converting OpenJava code with the multiextends keyword into java code (what you did for the example code). Explain the benefits and limitations of your strategy. More points will be awarded to strategies with limitations that are described in the writeup, than those that don't mention the limitations at all. Part 2: Readme (10%) Provide a readme file that details how your OpenJava code works, how to use it, what machine/OS you used it on. Also list the examples your code works with, and the ones it has trouble with. Automated Code Generation (40%) Your OpenJava code converts the example code to java code that runs with the desired behavior. If you've added new syntax to handle conflicts or other things, you can modify the example code appropriately and submit the modified code along with the rest of your assignment. Submission Requirements: Please submit a ZIP file with your code, including a README file with testing instructions and your working examples.  In the README file, place the names of each group member (up to three), and the version(s) of Java that you have tested it under.  Your code will be tested in the CS machines, so make sure it works there.  Your README file should also have a list of specific features / bugs in your solution. Your ZIP file should be named with your WebCT user name(s) as the filename, either userid1.zip or userid1_userid2.zip, or userid1_userid2_userid3.zip. Only submit one assignment per group via WebCT.