【精品文档】546关于计算机专业面向对象编程技术的毕业设计论文英文英语外文文献翻译成品资料:面向对象的Jython(中英文双语对照)

上传人:从****越 文档编号:126771539 上传时间:2020-03-27 格式:DOCX 页数:24 大小:873.93KB
返回 下载 相关 举报
【精品文档】546关于计算机专业面向对象编程技术的毕业设计论文英文英语外文文献翻译成品资料:面向对象的Jython(中英文双语对照)_第1页
第1页 / 共24页
【精品文档】546关于计算机专业面向对象编程技术的毕业设计论文英文英语外文文献翻译成品资料:面向对象的Jython(中英文双语对照)_第2页
第2页 / 共24页
【精品文档】546关于计算机专业面向对象编程技术的毕业设计论文英文英语外文文献翻译成品资料:面向对象的Jython(中英文双语对照)_第3页
第3页 / 共24页
【精品文档】546关于计算机专业面向对象编程技术的毕业设计论文英文英语外文文献翻译成品资料:面向对象的Jython(中英文双语对照)_第4页
第4页 / 共24页
【精品文档】546关于计算机专业面向对象编程技术的毕业设计论文英文英语外文文献翻译成品资料:面向对象的Jython(中英文双语对照)_第5页
第5页 / 共24页
点击查看更多>>
资源描述

《【精品文档】546关于计算机专业面向对象编程技术的毕业设计论文英文英语外文文献翻译成品资料:面向对象的Jython(中英文双语对照)》由会员分享,可在线阅读,更多相关《【精品文档】546关于计算机专业面向对象编程技术的毕业设计论文英文英语外文文献翻译成品资料:面向对象的Jython(中英文双语对照)(24页珍藏版)》请在金锄头文库上搜索。

1、本文是中英对照毕业设计论文外文文献翻译,下载后直接可用!省去你找文献、pdf整理成word和翻译的时间!一辈子也就一次的事!文献引用作者出处信息:Josh Juneau, Jim Baker, Victor Ng, Frank Wierzbicki, Leo Soto Muoz The Definitive Guide to Jython Python for the Java Platform,2020(如觉得年份太老,可改为近2年,毕竟很多毕业生都这样做)英文3811单词,21006字符(字符就是印刷符),中文5874汉字。(如果字数多了,可自行删减,大多数学校都是要求选取外文的一部分内容

2、进行翻译的。)Object-Oriented JythonThis chapter is going to cover the basics of object-oriented programming. Well start with covering the basic reasons why you would want to write object-oriented code in the first place, and then cover all the basic syntax, and finally well show you a non-trivial example.

3、Object-oriented programming is a method of programming where you package your code up into bundles of data and behavior. In Jython, you can define a template for this bundle with a class definition. With this first class written, you can then create instances of that class that include instance-spec

4、ific data, as well as bits of code called methods that you can call to do things based on that data. This helps you organize your code into smaller, more manageable bundles.With the release of Jython 2.5, the differences in syntax between the C version of Python and Jython are negligible. So, althou

5、gh everything here covers Jython, you can assume that all of the same code will run on the C implementation of Python, as well. Enough introduction thoughlets take a look at some basic syntax to see what this is all about.Basic SyntaxWriting a class is simple. It is fundamentally about managing some

6、 kind of “state” and exposing some functions to manipulate that state. In object jargon, we call those functions “methods.”Lets start by creating a Car class. The goal is to create an object that will manage its own location on a two-dimensional plane. We want to be able to tell it to turn and move

7、forward, and we want to be able to interrogate the object to find out where its current location is. Place the following code in a file named “car.py.”Well go over that class definition in detail but right now, lets just see how to create a car, move it around, and ask the car where it is.In Jython

8、there are things that are “callables.” Functions are one kind of callable; classes are another. So one way to think of a class is that its just a special kind of function, one that creates object instances.Once weve created the car instance, we can simply call functions that are attached to the Car

9、class and the object will manage its own location. From the point of view of our test code, we do not need to manage the location of the carnor do we need to manage the direction that the car is pointing in. We just tell it to move, and it does the right thing.Lets go over the syntax in detail to se

10、e exactly whats going on here.In Line 1 of car.py, we declare that our Car object is a subclass of the root “object” class. Jython, like many object-oriented languages, has a “root” object that all other objects are based off of. This “object” class defines basic behavior that all classes can reuse.

11、Jython actually has two kinds of classes: “new style” and old style. The old way of declaring classes didnt require you to type “object;” youll occasionally see the old-style class usage in some Jython code, but its not considered good practice. Just subclass “object” for any of your base classes an

12、d your life will be simpler. Lines 3 to 6 declare class attributes for the direction that any car can point to. These are class attributes, so they can be shared across all object instances of the Car object. Class attributes can be referenced without having to create an object instance.Now for the

13、good stuff.Lines 8-11 declare the object initializer method. This method is called immediately after your object is created and memory for it has been allocated. In some languages, you might be familiar with a constructor; in Jython, we have an initializer which is run after construction. Valid meth

14、od names in Jython are similar to many other C style languages. Generally, use method names that start with a letter; you can use numbers in the rest of the method name if you really want, but dont use any spaces. Jython classes have an assortment of special “magic” methods as well. These methods al

15、l start with a double underscore and end with a double underscore. These methods are reserved by the language and they have special meaning. So for our initializer “_init_,” the Jython runtime will automatically invoke that method once youve called your constructor with “Car().” There are other rese

16、rved method names to let you customize your classes further, and well get into those later.In our initializer, we are setting the initial position of the car to (0, 0) on a two-dimensional plane, and then the direction of the car is initialized to pointing north. When we initialize the object, we dont have to pass in the position explicitly. The function signature uses Jythons default argument l

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 期刊/会议论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号