欢迎来到三一文库! | 帮助中心 三一文库31doc.com 一个上传文档投稿赚钱的网站
三一文库
全部分类
  • 研究报告>
  • 工作总结>
  • 合同范本>
  • 心得体会>
  • 工作报告>
  • 党团相关>
  • 幼儿/小学教育>
  • 高等教育>
  • 经济/贸易/财会>
  • 建筑/环境>
  • 金融/证券>
  • 医学/心理学>
  • ImageVerifierCode 换一换
    首页 三一文库 > 资源分类 > DOC文档下载  

    英文翻译-基于mvc的跑步社区管理系统的设计与实现.doc

    • 资源ID:11132179       资源大小:254.04KB        全文页数:16页
    • 资源格式: DOC        下载积分:4
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录   微博登录  
    二维码
    微信扫一扫登录
    下载资源需要4
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    英文翻译-基于mvc的跑步社区管理系统的设计与实现.doc

    1外文资料翻译译文接口接口和抽象类提供了更加结构化的方式来实现接口分离。这样的机制在编程语言中并不常见。例如C +,只有对这些概念的间接支持。在Java中存在语言的关键字,这一事实表明,这些想法是重要的,足以提供直接的支持。首先,我们来看看抽象类,这是一种普通的类和接口之间的中间步骤。虽然第一步是创建一个接口,抽象类是用于构建有一些未实现的方法类的一个重要并且必要的工具。你不能总是用纯接口。抽象类和方法在前面的章节中所有的“乐器”的例子,在基类仪器的方法总是“虚拟”的方法。如果这些方法都曾经叫,你做错了什么。这是因为仪器的目的是创建一个通用接口,所有从它派生的类。在这些实施例中,唯一的原因来建立该共同界面是使得它可以为每个不同的亚型表达不同。它建立了一个基本形式,这样就可以说什么是适用于所有的派生类。的另一种说法是调用仪器的抽象基类,或者只是一个抽象类。如果你有一个抽象类像仪,特定类的对象几乎都是没有任何意义。当你想通过它的通用接口来操纵一组类,你创建一个抽象类。因此,仪器是为了只表达接口,而不是一个特定的实现,因此创建一个仪表对象是没有意义的,你可能会想阻止用户这样做。这可以通过使在仪器的所有方法产生错误来完成,但是这延迟的信息,直到运行时间并需要对用户的部分可靠详尽的测试。通常最好赶在编译时的问题。Java提供一种机制,用于执行此操作称为抽象method.1这是一种方法,该方法是不完全的;它只有一个声明,没有方法体。下面是语法的抽象方法声明。abstract void f( ); 包含抽象方法的类叫做抽象类。如果一个类包含一个或多个抽象方法,类本身必须是合格的抽象。 (否则,编译器给你一个错误信息。)如果一个抽象类是不完整的,什么是应该做的编译器,当有人试图使这一类的一个对象?它不能安全地创建一个抽象类的对象,所以你从编译器的错误信息。这样一来,编译器保证了抽象类的纯度,而且你不必担心误用。如果从一个抽象类继承,你想使新类型的对象,你必须提供方法定义为在基类中的所有抽象方法。如果不这样做(你可以选择不),则派生类也是抽象的,而且编译器会强迫你限定该类与抽象的关键字。这有可能使一个类抽象而不包括任何抽象方法。当你有一个类中,它没有任何意义有任何抽象方法,但要防止任何类实例,这非常有用。从前面的章节中的仪器类可以很容易地变成一个抽象类。只有一些方法将是抽象的,因为使一个类摘要不强迫你做的所有方法抽象。这里是什么样子:这是乐团示例修改为使用抽象类和方法:这是乐团示例修改为使用抽象类和方法:/: interfaces/music4/Music4.java / Abstract classes and methods. package interfaces.music4; import polymorphism.music.Note; import static net.mindview.util.Print.*; abstract class Instrument private int i; public abstract void play(Note n); public String what() return "Instrument" public abstract void adjust(); class Wind extends Instrument public void play(Note n) print("Wind.play() " + n); public String what() return "Wind" public void adjust() class Percussion extends Instrument public void play(Note n) print("Percussion.play() " + n); public String what() return "Percussion" public void adjust() class Stringed extends Instrument public void play(Note n) print("Stringed.play() " + n); public String what() return "Stringed" public void adjust() class Brass extends Wind public void play(Note n) print("Brass.play() " + n); public void adjust() print("Brass.adjust()"); class Woodwind extends Wind public void play(Note n) print("Woodwind.play() " + n); public String what() return "Woodwind" public class Music4 / Doesnt care about type, so new types / added to the system still work right: static void tune(Instrument i) / . i.play(Note.MIDDLE_C); static void tuneAll(Instrument e) for(Instrument i : e) tune(i); public static void main(String args) / Upcasting during addition to the array: Instrument orchestra = new Wind(), new Percussion(), new Stringed(), new Brass(), new Woodwind() ; /* Output: Wind.play() MIDDLE_C Percussion.play() MIDDLE_C Stringed.play() MIDDLE_C Brass.play() MIDDLE_C Woodwind.play() MIDDLE_C */: 你可以看到,除了基类其它没有改变。创建抽象类和方法是很有帮助的,因为他们的抽象性类显式,并告诉用户和编译器它是如何被使用。抽象类重构通行费也有用,因为它们允许您轻松地将常用的方法继承层次结构。接口接口关键字采用抽象的概念又进了一步。抽象的关键字,您可以创建一个或多个未定义的方法在一个类中,您所提供的接口的一部分而不提供相应的实现。实现由继承者提供。接口关键字产生一个完全抽象类,一个提供没有实现的。它允许创建者确定方法名称,参数列表和返回类型,但没有方法体。一个接口提供仅一种形式,但没有实现。接口说:“实现这个特定的接口中的所有类都将是这样。”因此,使用特定接口的任何代码知道什么方法可以被称为该接口,而这一切。所以界面用于建立类之间的“协议”。 (一些面向对象的编程语言有一个名为协议做同样的事情关键字。)然而,接口是多到了极致只是一个抽象类,因为它可以让你通过创建一个类,可以向上转型到多个基类来执行“多重继承”的变化。要创建一个接口,使用该接口的关键字,而不是class关键字。作为一类,可以在接口关键字前加上public关键字(但只有当该接口在同一个名称的文件中定义)。如果你离开过公众的关键字,你会得到包访问,所以接口是唯一在同一封装内使用。接口也可以包含字段,但这些都是隐式静态和最后。为了使一类符合特定接口(或一组接口),使用implements关键字,它说:“该接口是什么样子的,但现在我会说,它是如何工作的。”除此之外,它看起来像继承。该图的仪器例子显示了这一点:木管乐器和铜管的类中可以看到,一旦你实现了一个接口,实现成为一个普通的类,它可以扩展的常规方法。你可以选择显式地声明一个接口中的方法公开,但他们是公开的,即使你不会说。当你实现一个接口,接口必须被定义为公共的方法。否则,他们会默认包访问,你会减少在继承方法的可访问性,这是由Java编译器不允许。你可以看到这个修改版本的工具的例子。注意,接口中的每个方法是严格意义上的声明,编译器允许唯一。此外,没有一个方法声明为公共工具,但它们自动公共无论如何:/: interfaces/music5/Music5.java / Interfaces. package interfaces.music5; import polymorphism.music.Note; import static net.mindview.util.Print.*; interface Instrument / Compile-time constant: int VALUE = 5; / static & final / Cannot have method definitions: void play(Note n); / Automatically public void adjust(); class Wind implements Instrument public void play(Note n) print(this + ".play() " + n); public String toString() return "Wind" public void adjust() print(this + ".adjust()"); class Percussion implements Instrument public void play(Note n) print(this + ".play() " + n); public String toString() return "Percussion" public void adjust() print(this + ".adjust()"); class Stringed implements Instrument public void play(Note n) print(this + ".play() " + n); public String toString() return "Stringed" public void adjust() print(this + ".adjust()"); class Brass extends Wind public String toString() return "Brass" class Woodwind extends Wind public String toString() return "Woodwind" public class Music5 / Doesnt care about type, so new types / added to the system still work right: static void tune(Instrument i) / . i.play(Note.MIDDLE_C); static void tuneAll(Instrument e) for(Instrument i : e) tune(i); public static void main(String args) / Upcasting during addition to the array: Instrument orchestra = new Wind(), new Percussion(), new Stringed(), new Woodwind() ; tuneAll(orchestra); /* Output: Wind.play() MIDDLE_C Percussion.play() MIDDLE_C Stringed.play() MIDDLE_C Brass.play() MIDDLE_C Woodwind.play() MIDDLE_C */:另外一个变化已经取得了这个版本的例子:在 what( )方法已更改为的toString(),因为这是怎样的方法被使用。自的toString()是根类对象的一部分,它不需要出现在界面。代码的其余部分的工作原理相同。请注意,这并不重要,如果你是向上转型到“常规”类叫做仪器,一个抽象类仪器,或称为仪器的接口关系。的行为是相同的。事实上,你可以调tune( )方法中看到,是不是仪器是否是一个“普通”类,抽象类或接口的任何证据。2.外文原文InterfacesInterfaces and abstract classes provide more structured way to separate interface from implementation. Such mechanisms are not that common in programming languages. C+, for example, only has indirect support for these concepts. The fact that language keywords exist in Java indicates that these ideas were considered important enough to provide direct support. First, well look at the abstract class, which is a kind of midway step between an ordinary class and an interface. Although your first impulse will be to create an interface, the abstract class is an important and necessary tool for building classes that have some unimplemented methods. You cant always use a pure interface. Abstract classes and methods In all the “instrument” examples in the previous chapter, the methods in the base class Instrument were always “dummy” methods. If these methods are ever called, youve done something wrong. Thats because the intent of Instrument is to create a common interface for all the classes derived from it. In those examples, the only reason to establish this common interface is so that it can be expressed differently for each different subtype. It establishes a basic form, so that you can say whats common for all the derived classes. Another way of saying this is to call Instrument an abstract base class, or simply an abstract class. If you have an abstract class like Instrument, objects of that specific class almost always have no meaning. You create an abstract class when you want to manipulate a set of classes through its common interface. Thus, Instrument is meant to express only the interface, and not a particular implementation, so creating an Instrument object makes no sense, and youll probably want to prevent the user from doing it. This can be accomplished by making all methods in Instrument generate errors, but that delays the information until run time and requires reliable exhaustive testing on the users part. Its usually better to catch problems at compile time. Java provides a mechanism for doing this called the abstract method.1 This is a method that is incomplete; it has only a declaration and no method body. Here is the syntax for an abstract method declaration. abstract void f( ); A class containing abstract methods is called an abstract class. If a class contains one or more abstract methods, the class itself must be qualified as abstract. (Otherwise, the compiler gives you an error message.) If an abstract class is incomplete, what is the compiler supposed to do when someone tries to make an object of that class? It cannot safely create an object of an abstract class, so you get an error message from the compiler. This way, the compiler ensures the purity of the abstract class, and you dont need to worry about misusing it. If you inherit from an abstract class and you want to make objects of the new type, you must provide method definitions for all the abstract methods in the base class. If you dont (and you may choose not to), then the derived class is also abstract, and the compiler will force you to qualify that class with the abstract keyword. Its possible to make a class abstract without including any abstract methods. This is useful when youve got a class in which it doesnt make sense to have any abstract methods, and yet you want to prevent any instances of that class. The Instrument class from the previous chapter can easily be turned into an abstract class. Only some of the methods will be abstract, since making a class abstract doesnt force you to make all the methods abstract. Heres what it looks like: Heres the orchestra example modified to use abstract classes and methods: /: interfaces/music4/Music4.java / Abstract classes and methods. package interfaces.music4; import polymorphism.music.Note; import static net.mindview.util.Print.*; abstract class Instrument private int i; / Storage allocated for each public abstract void play(Note n); public String what() return "Instrument" public abstract void adjust(); class Wind extends Instrument public void play(Note n) print("Wind.play() " + n); public String what() return "Wind" public void adjust() class Percussion extends Instrument public void play(Note n) print("Percussion.play() " + n); public String what() return "Percussion" public void adjust() class Stringed extends Instrument public void play(Note n) print("Stringed.play() " + n); public String what() return "Stringed" public void adjust() class Brass extends Wind public void play(Note n) print("Brass.play() " + n); public void adjust() print("Brass.adjust()"); class Woodwind extends Wind public void play(Note n) print("Woodwind.play() " + n); public String what() return "Woodwind" public class Music4 / Doesnt care about type, so new types / added to the system still work right: static void tune(Instrument i) / . i.play(Note.MIDDLE_C); static void tuneAll(Instrument e) for(Instrument i : e) tune(i); public static void main(String args) / Upcasting during addition to the array: Instrument orchestra = new Wind(), new Percussion(), new Stringed(), new Brass(), new Woodwind() ; /* Output: Wind.play() MIDDLE_C Percussion.play() MIDDLE_C Stringed.play() MIDDLE_C Brass.play() MIDDLE_C Woodwind.play() MIDDLE_C */: You can see that theres really no change except in the base class. Its helpful to create abstract classes and methods because they make the abstractness of a class explicit, and tell both the user and the compiler how it was intended to be used. Abstract classes are also useful refactoring tolls, since they allow you to easily move common methods up the inheritance hierarchy. Interfaces The interface keyword takes the concept of abstractness one step further. The abstract keyword allows you to create one or more undefined methods in a classyou provide part of the interface without providing a corresponding implementation. The implementation is provided by inheritors. The interface keyword produces a completely abstract class, one that provides no implementation at all. It allows the creator to determine method names, argument lists, and return types, but no method bodies. An interface provides only a form, but no implementation. An interface says, "All classes that implement this particular interface will look like this." Thus, any code that uses a particular interface knows what methods might be called for that interface, and thats all. So the interface is used to establish a "protocol" between classes. (Some object-oriented programming languages have a keyword called protocol to do the same thing.) However, an interface is more than just an abstract class taken to the extreme, since it allows you to perform a variation of "multiple inheritance" by creating a class that can be upcast to more than one base type. To create an interface, use the interface keyword instead of the class keyword. As with a class, you can add the public keyword before the interface keyword (but only if that interface is defined in a file of the same name). If you leave off the public keyword, you get package access, so the interface is only usable within the same package. An interface can also contain fields, but these are implicitly static and final. To make a class that conforms to a particular interface (or group of interfaces), use the implements keyword, which says, "The interface is what it looks like, but now Im going to say how it works." Other than that, it looks like inheritance. The diagram for the instrument example shows this: You can see from the Woodwind and Brass classes that once youve implemented an interface, that implementation becomes an ordinary class that can be extended in the regular way. You can choose to explicitly declare the methods in an interface as public, but they are public even if you dont say it. So when you implement an interface, the methods from the interface must be defined as public. Otherwise, they would default to package access, and youd be reducing the accessibility of a method during inheritance, which is not allowed by the Java compiler. You can see this in the modified version of the Instrument example. Note that every method in the interface is strictly a declaration, which is the only thing the compiler allows. In addition, none of the methods in Instrument are declared as public, but theyre automatically public anyway: /: interfaces/music5/Music5.java / Interfaces. package interfaces.music5; import polymorphism.music.Note; import static net.mindview.util.Print.*; interface Instrument / Compile-time constant: int VALUE = 5; / static & final / Cannot have method definitions: void play(Note n); / Automatically public void adjust(); class Wind implements Instrument public void play(Note n) print(this + ".play() " + n); public String toString() return "Wind" pub

    注意事项

    本文(英文翻译-基于mvc的跑步社区管理系统的设计与实现.doc)为本站会员(scccc)主动上传,三一文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    经营许可证编号:宁ICP备18001539号-1

    三一文库
    收起
    展开