SpecialistOff.NET / Вопросы / Статьи / Фрагменты кода / Резюме / Метки / Помощь / Файлы

Назад

Exercises


Метки: python

  1. Modify GreenHouseLanguage.py so that it checks the times for the events and runs those events at the appropriate times.
  2. Modify GreenHouseLanguage.py so that it calls a function for action instead of just printing a string.
  3. Create a Swing application with a JTextField (where the user will enter commands) and a JTextArea (where the command results will be displayed). Connect to a PythonInterpreter object so that the output will be sent to the JTextArea (which should scroll). You’ll need to locate the PythonInterpreter command that redirects the output to a Java stream.
  4. Modify GreenHouseLanguage.py to add a master controller class (instead of the static array inside Event) and provide a run() method for each of the subclasses. Each run() should create and use an object from the standard Java library during its execution. Modify GreenHouseController.java to use this new class.
  5. Modify the resulting GreenHouseLanguage.py from exercise two to produce Java classes (add the @sig documentation strings to produce the correct Java signatures, and create a makefile to build the Java .class files). Write a Java program that uses these classes.
  6. Modify GreenHouseLanguage.py so that the subclasses of Event are not discrete classes, but are instead generated by a single function which creates the class and the associated string dynamically.

Footnotes

[1] The original version of this was called JPython, but the project changed and the name was changed to emphasize the distinctness of the new version.
[2] Changing the registry setting python.security.respectJavaAccessibility = true to false makes testing even more powerful because it allows the test script to use all methods, even protected and package- private.