+ All Categories
Home > Documents > Proyect of english

Proyect of english

Date post: 20-Jul-2015
Category:
Upload: carlos-alcivar
View: 56 times
Download: 3 times
Share this document with a friend
14
Transcript
Page 1: Proyect of english
Page 2: Proyect of english

UNIVERSITY TECHNICAL OF MANABÍ

MISSION:

Being academics, scientists and professionals responsible, humanistic, ethical and caring,

committed to the goals of national development, which contribute to solving the country's

problems as university teaching with research, able to generate and apply new knowledge,

encouraging the promotion and dissemination of knowledge and culture, under the Constitution

of the Republic of Ecuador.

VISION:

To be university institution, leader and relating of the superior education in the Ecuador,

promoting the creation, development, transmission and diffusion of the science, the technique

and the culture, with social recognition and regional and world projection.

FACULTY OF COMPUTERS SCIENCES

MISSION:

To be an unit with high academic prestige, with efficiency, transparency and quality in the

education, organized in their activities, main characters of the regional and national progress.

VISION:

To form efficient and innovative professionals in the field of the computer sciences that with

honesty, justness and solidarity, give answers to the necessities of the society elevating their level

of life.

Page 3: Proyect of english

Project of English

PROGRAMMING II

How to start programming in JAVA

This part of the study material is not intended to address still concepts, but rather, you can

configure any computer windowXP or Windows7 of 32 or 64 bit and get it ready to start

programming.

We install “jdk-7u7-nb-7_2-windows-i586-ml”, el JDK “Java Development Kit”, This will not only run

applications if not compile, available for a variety of operating systems.

Page 4: Proyect of english

Use the Shell to run java code:

Javac.exe. - Compiler that generates files *.class from source (*.java). The *.Java is text, you can

create and edit in a text editor, using the syntax of Java.

Java.exe. - Interpreter systems PC / Windows, runs bytecode files (files compiled class extension).

The *.Class has executable code, bytecode, platform independent, to be executed on a

"hypothetical or virtual machine" called Java Virtual Machine (JVM). Is this JVM neutral that plays

this code making a particular code on the CPU used. This avoids having to make a different

program for each CPU.

Using the Eclipse Integrated Development Environment

This method is much faster than before, it is a method of abstraction for programming while we

should not install the JDK, and load the necessary libraries to program without tread very rodeo.

STEP 1: Download and unzip the file indicated.

Page 5: Proyect of english

STEP 2: After that opening the Eclipse IDE, the program requests a folder where you will save the

projects that we believe in java, proceed as indicated in the graph (you must create the folder

previously).

STEP 3: Follow the following sequence of actions to create a project in java.

Page 6: Proyect of english

The JDK Java

JDK stands for Java Developers Kit That is, toolset for develop (applications) in Java. There

countless classes accompanying the JDK that are installed for power get start programming in

JAVA.

What makes it different to other JAVA programming languages?

What distinguishes Java from other programming languages is its conception of departure, in

which language is to create a road that can be used to program in all types of operating systems

and processors. One of the most important features is that the programs "executable", created by

the Java compiler, is independent of the architecture. Run interchangeably in a variety of

microprocessors and computers with different operating systems.

Is the language is compiled or interpreted?

Java is compiled when the source code is translated into an object called machine code (binary,

bytecode) and is interpreted because the machine code can be run on any platform which should

be an interpreter executing it in real time. To run it, you need an interpreter, the JVM (JavaVirtual

Machine) Java virtual machine. Thus, it is possible to compile the program on a UNIX workstation

and run it on another Windows using the Java virtual machine for Windows. This JVM is

responsible for reading the bytecodes and translate them into executable instructions directly on a

particular microprocessor.

The Java Virtual Machine (JVM).

The Java virtual machine is the revolutionary idea of language. It is the entity that provides

platform independence for Java programs compiled into byte-code.

Page 7: Proyect of english

JAVA PRIMITIVE DATA

There are a bunch of guys that are used very often in programming and require special treatment.

Types can be considered as "primitive", the reason for this special treatment is that to create a

new object, a simple variable small, not efficient. To these primitive types, Java uses the technique

used in C and C + +, that is, instead of creating the new variable creates a variable "automatic" is

not a reference.

Java determines the size of each primitive type. These sizes do not change from one machine

architecture to another. This invariability of the sizes is one of the reasons of portability java.

DEFAULTS PRIMITIVE MEMBERS

When a primitive data type as a member of a class, Java guarantees that you will be assigned a

default value if it fails to boot

The defaults are only the values that Java guarantees when the variable is used as a class member.

This ensures that the member variables of primitive type always be initialized (something C + +

does not do), reducing a source of potential errors. However, this initial value may not be correct

or even legal for the program you are writing. It is best to always initialize variables explicitly. This

warranty does not apply to initialize local variables, those that are not class fields.

Classes. - This is a data type which is created by the user.

Object. - Is one that defined through a class has an identity.

Java can run on any operating system.

The bytecode is an extension. Class.

Page 8: Proyect of english
Page 9: Proyect of english

OPERATORS IN JAVA

Java basic operators are +, -, *, / for addition, subtraction, multiplication and division. the operator

/ Represents integer division if both operand are integers, the module can be obtained by the

operator% (7/4 = 1, 7% 4 = 3).

There are also decrement and increment operators: "-" and "+ +" respectively. The operation they

perform are increment and decrement by one unit to the variable that is applied. His action is

different as they apply before (+ + a) or after (a + +) of the variable. The following program

illustrates these different effects:

example:

public class Ejemplo2{

public static void main(String[] args) {

int i = 1;

prt("i : " + i);

prt("++i : " + ++i); // Pre-incremento, primero

//incrementa y luego imprime por consola

prt("i++ : " + i++); // Post-incremento, primero imprime

//“2” por consola y luego incrementa i. prt("i : " + i);//i por lo tanto vale 3

prt("--i : " + --i); // Pre-decremento, primero

//decrementa i y luego lo imprime por consola

prt("i-- : " + i--); // Post-decremento, primero imprime

//i por consola y luego de decrementa. prt("i : " + i);//Ahora i vale 1

}

//esto nos ahorrara teclear. Invocando a prt podremos

//imprimir por consola la cadena de caracteres que le pasemos static void

prt(String s) {

System.out.println(s);

}

}

Page 10: Proyect of english

LOGICAL OPERATORS

In the table below we collect the logical operators in Java:

Logical operators:

Operator

Operation Performed

!

Not logical

==

Test of equality

!=

Test for inequality

<

Less tan

>

greater que

<=

Less than or equal

>=

Greater than or equal

&&

And logical

||

Or lógical

The following example shows the function of these operators:

import java.util.*;

public class Ejemplo3 {

public static void main(String[] args) {

//Creamos un objeto de tipo Random almacenado un puntero a, el en la variable rand.

Random rand = new Random();

/*el método nextInt() del objeto Random creado (se invoca como rand.nextInt()) genera un número

aleatorio entero. En El módulo 100 de un entero aleatorio será un entero aleatorio entre 0 y 100.*/

int i = rand.nextInt() % 100;

int j = rand.nextInt() % 100;

//Imprime I y j por consola prt("i = " + i);

prt("j = " + j);

//Imprime diversas operaciones binarias sobre i y j, junto

//con su resultado. prt("i

> j es " + (i > j)); prt("i < j

es " + (i < j)); prt("i >= j es

" + (i >= j));

prt("i <= j es " + (i <= j)); prt("i == j es " + (i == j));

prt("i != j es " + (i != j));

prt("(i < 10) && (j < 10) es "+ ((i < 10) && (j < 10)) );

prt("(i < 10) || (j < 10) es "+ ((i < 10) || (j < 10)) );

}

static void prt(String s) { System.out.println(s);}}}

Page 11: Proyect of english

CHAINS OF CHARACTERS In Java there is a predefined type for character strings instead there is a string that is the support

for various operations with strings. The definition of a string is:

String and / / not initialized

String e = "" / / empty string

String e = "Hello" / / initialization and assignment together.

Objects and Classes

Java is a fully object-oriented language, much more than for example C + +. In Java everything is an

object except for the basic types of integer variables, real and char.

In the 60s the programming was done in a "classic" (not OO). A program was a code that ran the

pieces of code that could be used repeatedly throughout the program (reuse) were written in the

form of procedures that were invoked from the program and this was the only ability to re-use

possible code.

According codes were becoming larger and more complex programming this style became more

feasible as it is difficult to schedule something large with this style of programming. The only

possibility of sharing code snippets are relatively independent programmers and end procedures

have to join all these with the core program that calls being frequently encounter problems when

joining these pieces of code.

Classes and Inheritance

A class is the "template" that we use to create the objects. All objects belong to a certain class. An

object that is created from a class is said to be an instance of that class. Different classes have

different inheritance relationships among themselves. A class can be derived from the other in this

case the derived class or child class inherits the methods and variables of the class that is derived

or parent class. In Java all classes have the same father as first class Object class.

For simplicity and given the short duration of this course ignore the existence of the package

concept in explaining these concepts or make brief references to this concept without much

explanation. In general terms what the student is recommended for at least ignoring this course

any reference to the term "package".

Come now to delve into all of these concepts and explain their syntax in Java.

Definition of a class. - The most general definition of a class in Java is: [Modifier] class classname

[extends nombreClasePadre] [implements interface] {

Declaration of variables, methods Declaration;}

Page 12: Proyect of english

Fields are enclosed in brackets are optional. className is the name you want to give to our class,

nombreClasePadre is the name of the parent class from which it inherits the methods and

variables. Regarding the content of the last bracket as explained below its meaning. The possible

modifiers class properties. Here you have options:

MODIFY CLASS

Public. - The class is public and therefore accessible to everyone. We can only have one public

class per compilation unit but may not have any.

None. - The class is "friendly". It will be accessible to other classes of package. But while all classes

that are working are in the same directory belong to the same package and therefore will be as if

they were public. As of now at work in a single directory assume that the absence of modifier is

equivalent to the class is public.

Final. - Indicate that this class can not "have child" can not derive any kind of it.

Abstract. - This is a class which can not instantiate any object. An example Java class:

class Animal{

int edad; String nombre;

public void nace(){

System.out.println("Hola mundo");

}

public void getNombre(){ System.out.println(nombre);

}

public void getEdad(){ System.out.println(edad);

}

BUILDERS

Constructors are methods whose name matches the name of the class and never return any data

type, not necessary to indicate the return type is void. Constructors are used to initialize the

values of objects and perform operations necessary for the generation of this object (create other

objects that may be contained within this object, open a file or an internet connection).

Like any method supports a constructor overload. When we create an object (as we will see later

how to do) we can invoke the constructor that suits us.

class Animal{

int edad;

String nombre;

public Animal(){

}

Page 13: Proyect of english

public Animal(int _edad, String _nombre){

edad = _edad;

nombre = _nombre;

}

public void nace(){ System.out.println("Hola mundo");

}

public void getNombre(){ System.out.println(nombre);

}

public void getNombre(int i){ System.out.println(nombre +" " +edad);

MODIFIERS OF VARIABLES

Public. - Public it can consent everybody to that variable.

None. - it is "friendly" it can be consented by any member of the package but not for other classes

that belong to another different package.

Protected. - Protected they can only consent to her the classes daughters of the class that it

possesses the variable and those that are in the same package.

Deprive you. - Private nobody except for the same class can consent to these variables. They can

consent to her all the instances of the class (when we say class we are referring to all their possible

instances)

Static. - Static this variable is the same one for all the instances of a class all they share that fact. If

an instance modifies it all they come this modification.

Final. - Final it is used to define constant a fact final type can never vary its value. The variable

doesn't have reason to be initialized in the moment to be defined but when it is initialized it can

no longer change its value.

MODIFIERS OF A METHOD

Public. - Public it can consent everybody to this method.

None. - it is "friendly" it can be consented by any member of the package but not for other classes

that belong to another package.

Protected. - Protected they can only consent to her the classes daughters of the class that it

possesses the method and those that are in the same package.

Deprive you. - Private nobody except for the same class can consent to these methods.

Page 14: Proyect of english

Static. - Static is a method to which you can invoke without creating any object of this class.

Math.sin, Math.cos is two examples of static methods. From a static method we can only invoke

other methods that are also static.

Final. - Final it is a method that he/she won't be able to be changed by any class that inherits of

the class where he/she was defined. It is a method that one is not able to "to overwrite". later on

it will be explained that it is this.

INHERITANCE

When in Java we indicate that a class "extends" another class is indicating that it is a class

daughter of this and that therefore it inherits all its methods and variables. This is a powerful

mechanism for the reusabilidad of the code. We can inherit reason why of a class we leave of their

structure of variables and methods he/she stops then to add what we need or to modify what

doesn't adapt to our requirements.

CREATION AND IT INDEXES TO OBJECTS

Although we have already seen as an object it is believed we will formalize it a little. An object in

the computer is essentially by heart a block with space to keep the variables of this object. To

create the object is synonymous of reserving space for their variables to initialize it it is to give a

value to these variables. To create an object the command new it is used.

USE OF THE METHOD THIS

It is a special variable of only reading that Java provides. It contains a reference to the object in

which this variable is used. It is sometimes useful that an object can be indexed itself:


Recommended