Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
203
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Universidad Técnica de ManabíFacultad de Ciencias Informáticas Carrera Ingeniera en Sistema Asignatura Ingles Project of English: Docente tutor: Danny Jarred Integrantes: Mastarreno Macías Luis Miguel 3ero Semestre “C”Periodo: Septiembre 2012-Frebrero 2013
  • 2. UNIVERSIDAD TÉCNICA DE MANABÌ Misión:Formar académicos, científicos y profesionales responsables, humanistas,éticos y solidarios, comprometidos con los objetivos del desarrollo nacional,que contribuyan a la solución de los problemas del país como universidad dedocencia con investigación, capaces de generar y aplicar nuevosconocimientos, fomentando la promoción y difusión de los saberes y lasculturas, previstos en la Constitución de la República del Ecuador. Visión:Ser institución universitaria, líder y referente de la educación superior enel Ecuador, promoviendo la creación, desarrollo, transmisión y difusión de laciencia, la técnica y la cultura, con reconocimiento social y proyecciónregional y mundial. FACULTAD DE CIENCIAS INFORMÀTICAS Misión:Ser una unidad con alto prestigio académico, con eficiencia, transparencia ycalidad en la educación, organizada en sus actividades, protagonistas delprogreso regional y nacional. Visión: Formar profesionales eficientes e innovadores en el campo de las cienciasinformáticas, que con honestidad, equidad y solidaridad, den respuestas alas necesidades de la sociedad elevando su nivel de vida.
  • 3. PROGRAMMING IN JAVAJava language is a general purpose development, and as such is valid for allkinds of professional applications.Language Features.· It is inherently object-oriented.· Works great networking.· Leverage features of most modern languages avoiding drawbacks. Inparticular, the C + +.· It has great functionality with its libraries (classes).The Java language can be seen as an evolution of C + +. The syntax is similarto this language, so that in this book will refer to the language frequently.The Java Virtual Machine (JVM)The Java virtual machine is the idea of language revolucionaria4. It is theentity that provides platform independence for Java programs "Compiled"into byte-code.JDK (Java Developers Kit)The basic tool to start developing Java applications or applets is the JDK(Java Developers Kit) or Java Development Kit, which consists basically, ina compiler and an interpreter (JVM) for the command line. It has anintegrated development environment (IDE), but it is enough to learnlanguage and develop small applications. Object Oriented ProgrammingThe object-oriented programming is a natural evolution of programmingstructured, in which the concept of variables local to a procedure orfunction, which are not accessible to other procedures and functions, it isextensible to own applets that access to these variables. But OOP goes farbeyond.In object-oriented programming, objects are defined that make up aapplication. These objects are formed by a series of features andoperations that can be performed on them.
  • 4. ObjectAn object is a person, animal or thing. It is distinguished from otherobjects by having certain characteristics and "serves" to something, or putanother way, can perform various operations with / on that object.For example: A house is an object.FEATURES: Number of floors, Total height in meters Color the facade,number of windows, door number, city, street and number where it islocated, etc..OPERATIONS: Build, destroy, painted facade, modify some features, forexample, open a new window, etc.In terminology of object-oriented programming, the characteristics ofobject are called attributes and operations METHODS. Everyone of thesemethods is a procedure or a function belonging to an object. Classes and ObjectsIn OOP we must distinguish between two closely related concepts, the classand object.The way to declare objects in Java is:Ccasa casa1, house2;In this case, house2 casa1 and variables are effectively but somewhatspecial, are objects. Furthermore, the type of objects is Ccasa.This type is the kind of object.Properties must meet a language to be Object Oriented considered.· Encapsulation.· HERITAGE.· Polymorphism.EncapsulationEncapsulation is the property possessed objects hide their attributes, andeven methods to other parts of the program or other objects. The naturalway to build a class is to define a set of attributes, in general, are notaccessible outside of the same object, but can only modified throughmethods that are defined as available from outside of that class.class Ccasa {int nPuertas, nVentanas;
  • 5. String color;public Ccasa(int np, int nv, String co) {nPuertas=np;nVentanas=nv;color=co;}public void pintar(String co) {color=co;}public void abrirVentanas(int n) {nVentanas=nVentanas+n;}public void cerrarVentanas(int n) {nVentanas=nVentanas-n;if (nVentanas<0)nVentanas=0;}public void abrirPuertas(int n) {nPuertas=nPuertas+n;}public void cerrarPuertas(int n) {nPuertas=nPuertas-n;if (nPuertas<0)nPuertas=0;}}…Ccasa casa1,casa2;…HeredityOne of the main advantages of OOP. This property allows you to definedescendants of other classes, such that the new class (class descendant)predecessor class inherits all its attributes and methods. the new class candefine new attributes and methods or attributes can redefine and existingmethods (for example, change the type of an attribute or operationsperformed by a particular method).This property enables code reuse and is very easy to grasp the existingclass code, modifying them to suit the minimally new specifications.Example: Suppose you have built and want Ccasa class define a new classthat represents the chalets. In this case it may be convenient to define anew attribute that represents the square footage of garden. Instead ofredefining a new class "from scratch", can written to exploit the class codeas follows Ccasa.
  • 6. Ccasa Cchalet class extends {mJardin int;public Cchalet (int np, int nv, co String, int nj) {super (np, nv, co);mJardin = nj;}}...Cchalet chalet1, chalet2;...Class CcasanPuertasnVentanascolor...abrirVentanas ()cerrarVentanas ()paint ()abrirPuertas ()cerrarPuertas ()class CchaletnPuertasnVentanascolormJardin...abrirVentanas ()cerrarVentanas ()paint ()abrirPuertas ()cerrarPuertas ()As can be seen, only have to declare the new class Cchalet is descendedfrom Ccasa (extends Ccasa) and declare the new attribute. Clearly, the
  • 7. method must constructor to redefine initialize the new attribute mJardin.But methods to open / close doors or windows is not necessary .Theconstructor is a special method with the same name as the class and whosefunction is to initialize the attributes of each object (instance).Defining, are inherited from class Ccasa and can be used, for example ofthe follows:chalet1.pintar ("White");PolymorphismPolymorphism allows a single message sent to class objects different thenthese also behave differently (different objects can have methods withthe same name or the same object can methods have identical names butdifferent parameters).class Ccasa {…public Ccasa(int np, int nv, String co) {nPuertas=np;nVentanas=nv;color=co;}public Ccasa() {nPuertas=0;nVentanas=0;color=””;}You have two methods with the same name but different parameters. In hefirst If attributes are initialized object method parameters and thesecond case is initialized to zero, for example. Also, if you have two objectsand chalet1 casa1 and calls the method chalet1.abrirVentanas (2) will runthe procedure code abrirVentanas Cchalet class and not Ccasa class. Hello, world.First, lets see what structure should have the typical program whichstarts in any programming language that provides a first view of thelanguage syntax and begins transmitting a series of feelings of acceptanceor rejection by the programmer. the program simply will display themessage "Hello, world" and terminates.
  • 8. class Hello {public static void main (String args []) {System.out.println ("hello, world");}}Everything written in Java alone program starts running (as in C) from themain () method. Classes may be compiled not have main () method, but cannot run Java interpreter initially, but they can run if called from anotherrunning method. We will see in later chapters how creating applets isdifferent and does not declare this method.Statement of the main () method:· Public: indicates that the method main () is public and therefore can becalled from other classes. All main () method must be public to run fromthe Java interpreter (JVM).· Static: indicates that the class does not need to be instantiated use themethod that qualifies. (Not create any instance or Hello class object). Italso indicates that the method is the same for all instances that may becreated.· Void: indicates that the main function returns no value.· The main method must always accept, as a parameter, a vector stringsthat contain the possible arguments that are passed to program on thecommand line, but as in our case, no is used.The main () method is always declared in the same way: public static void main (String args [])Data TypesIn Java there are two main types of data:1) Simple Data Types.2) References to objects.The data types are those that can be used directly in a program, withoutthe use of classes (OOP). These types are:Byte, short, int, long, float, double, char, Boolean.
  • 9. Data Types referenceAll other data types that are not simple, are considered benchmarks.These guys are basically the classes, which is based programmingobject oriented.Scope of a variableThe scope of a variable is the portion of the program where the variable isvisible to the program code and, therefore, referenceable.The scope of a variable depends on the location of the program where it isdeclared, may belong to four different categories.· Local Variable.· Attribute.· A method parameter.· Parameter of an exception handler.Local VariableA local variable is declared within the body of a method of a class and isvisible only within that method.AttributesThe attributes of a class are the features to be taken into account on anobject and hence its area is limited, in principle, within the class to whichcharacterize.Alternative structuresAlternative structures are structures that allow you to alter the flowa sequential program so that depending on a condition or valueof an expression, the same can be diverted in either alternativecode.if-elseSimple:if (expression)Block instructionsThe statement block is executed if, and only if, the expression (which mustbe logic) evaluates to true, ie a certain condition is met.
  • 10. SwitchSimple:switch (expression) {case value1: instrucciones1;case value2: instrucciones2;...valueN case: instruccionesN;}In this case, unlike the above, whether or instrucciones2 or instrucciones1instruccionesN are formed by a single block of instructions, it isparentizarlas required by the braces ({...}).LoopsLoops are repeat structures. Blocks of instructions that repeat a numberof times while a condition is met or until enforcing a condition.Loop forfor (initialization, condition, increment)block instructions· The initialization clause is a statement that executes a single After thestart of the loop, typically to initialize a counter.The condition clause is a logical expression that evaluates to top each newiteration of the loop.The increase clause is a statement that is executed in each iteration of theloop as if it were the last statement in the statement block.Do-while loop.doblock instructionswhile (Expression);In this type of loop instruction block is executed once so long less, and thatblock of instruction will be executed while expression evaluates to true.While loopwhile (Expression)block instructions
  • 11. As in do-while loop in the previous section, the statement block is executedwhile a condition is met (while expression evaluates to true), but in thiscase, the condition is checked before start first run loop, so if expressionevaluates to false in the first iteration, then the statement block will notexecute any time.VectorsTo handle collections of objects of the same type in a single structuredvectores12 variable is used. In Java, the vectors are actually objects andtherefore it can call its methods (as discussed in the next chapter).There are two equivalent ways to declare vectors in Java:1) type nombreDelVector [];2) type [] nombreDelVector;Declaration of the superclass (inheritance)The superclass is the class from which another class inherits all theattributes and methods. The way to declare that a class inherits fromanother is:class ClassName extends NombreSuperclaseexample:Nif class extends DniDeclares a class that inherits Nif all attributes andDni class methods.AbstractAbstract classes can not be instanciadas17. These are for declaresubclasses should override those methods that have been declaredabstract. This does not mean that all methods of an abstract classabstractos18 should be even possible that none of them is. Even in thislatter case, the class is considered abstract and not be declared Objectsof this class.When any of the methods of a class is declared abstract class mustabstract necessarily be, otherwise, the compiler generates a messageerror.