本文是中英对照毕业设计论文外文文献翻译,下载后直接可用!省去你找文献、pdf整理成word和翻译的时间!一辈子也就一次的事!
文献引用作者出处信息:Josh Juneau, Jim Baker, Victor Ng, Frank Wierzbicki, Leo Soto Mu?oz The Definitive Guide to Jython Python for the Java Platform,2020(如觉得年份太老,可改为近2年,毕竟很多毕业生都这样做)
英文3811单词,21006字符(字符就是印刷符),中文5874汉字。(如果字数多了,可自行删减,大多数学校都是要求选取外文的一部分内容进行翻译的。)
Object-Oriented Jython
This chapter is going to cover the basics of object-oriented programming. We’ll 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 we’ll show you a non-trivial example.
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-specific 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, although 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 though—let’s take a look at some basic syntax to see what this is all about.
Basic Syntax
Writing a class is simple. It is fundamentally about managing some kind of “state” and exposing some functions to manipulate that state. In object jargon, we call those functions “methods.”
Let’s 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 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.”
We’ll go over that class def