Proyecto

12
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 3 ero Semestre “C” Periodo: Septiembre 2012-Frebrero 2013

description

 

Transcript of Proyecto

Page 1: Proyecto

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

Page 2: Proyecto

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 de

docencia con investigación, capaces de generar y aplicar nuevos

conocimientos, fomentando la promoción y difusión de los saberes y las

culturas, 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 en

el Ecuador, promoviendo la creación, desarrollo, transmisión y difusión de la

ciencia, la técnica y la cultura, con reconocimiento social y proyección

regional y mundial.

FACULTAD DE CIENCIAS INFORMÀTICAS

Misión:

Ser una unidad con alto prestigio académico, con eficiencia, transparencia y

calidad en la educación, organizada en sus actividades, protagonistas del

progreso regional y nacional.

Visión:

Formar profesionales eficientes e innovadores en el campo de las ciencias

informáticas, que con honestidad, equidad y solidaridad, den respuestas a

las necesidades de la sociedad elevando su nivel de vida.

Page 3: Proyecto

PROGRAMMING IN JAVA

Java language is a general purpose development, and as such is valid for all

kinds of professional applications.

Language Features.

· It is inherently object-oriented.

· Works great networking.

· Leverage features of most modern languages avoiding drawbacks. In

particular, the C + +.

· It has great functionality with its libraries (classes).

The Java language can be seen as an evolution of C + +. The syntax is similar

to 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 the

entity that provides platform independence for Java programs "Compiled"

into byte-code.

JDK (Java Developer's Kit)

The basic tool to start developing Java applications or applets is the JDK

(Java Developer's Kit) or Java Development Kit, which consists basically, in

a compiler and an interpreter (JVM) for the command line. It has an

integrated development environment (IDE), but it is enough to learn

language and develop small applications.

Object Oriented Programming

The object-oriented programming is a natural evolution of programming

structured, in which the concept of variables local to a procedure or

function, which are not accessible to other procedures and functions, it is

extensible to own applets that access to these variables. But OOP goes far

beyond.

In object-oriented programming, objects are defined that make up a

application. These objects are formed by a series of features and

operations that can be performed on them.

Page 4: Proyecto

Object

An object is a person, animal or thing. It is distinguished from other

objects by having certain characteristics and "serves" to something, or put

another 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 is

located, etc..

OPERATIONS: Build, destroy, painted facade, modify some features, for

example, open a new window, etc.

In terminology of object-oriented programming, the characteristics of

object are called attributes and operations METHODS. Everyone of these

methods is a procedure or a function belonging to an object.

Classes and Objects

In OOP we must distinguish between two closely related concepts, the class

and object.

The way to declare objects in Java is:

Ccasa casa1, house2;

In this case, house2 casa1 and variables are effectively but somewhat

special, 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.

Encapsulation

Encapsulation is the property possessed objects hide their attributes, and

even methods to other parts of the program or other objects. The natural

way to build a class is to define a set of attributes, in general, are not

accessible outside of the same object, but can only modified through

methods that are defined as available from outside of that class. class Ccasa {

int nPuertas, nVentanas;

Page 5: Proyecto

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;

Heredity

One of the main advantages of OOP. This property allows you to define

descendants of other classes, such that the new class (class descendant)

predecessor class inherits all its attributes and methods. the new class can

define new attributes and methods or attributes can redefine and existing

methods (for example, change the type of an attribute or operations

performed by a particular method).

This property enables code reuse and is very easy to grasp the existing

class code, modifying them to suit the minimally new specifications.

Example: Suppose you have built and want Ccasa class define a new class

that represents the chalets. In this case it may be convenient to define a

new attribute that represents the square footage of garden. Instead of

redefining a new class "from scratch", can written to exploit the class code

as follows Ccasa.

Page 6: Proyecto

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 Ccasa

nPuertas

nVentanas

color

...

abrirVentanas ()

cerrarVentanas ()

paint ()

abrirPuertas ()

cerrarPuertas ()

class Cchalet

nPuertas

nVentanas

color

mJardin

...

abrirVentanas ()

cerrarVentanas ()

paint ()

abrirPuertas ()

cerrarPuertas ()

As can be seen, only have to declare the new class Cchalet is descended

from Ccasa (extends Ccasa) and declare the new attribute. Clearly, the

Page 7: Proyecto

method must constructor to redefine initialize the new attribute mJardin.

But methods to open / close doors or windows is not necessary .The

constructor is a special method with the same name as the class and whose

function is to initialize the attributes of each object (instance).

Defining, are inherited from class Ccasa and can be used, for example of

the follows:

chalet1.pintar ("White");

Polymorphism

Polymorphism allows a single message sent to class objects different then

these also behave differently (different objects can have methods with

the same name or the same object can methods have identical names but

different 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 he

first If attributes are initialized object method parameters and the

second case is initialized to zero, for example. Also, if you have two objects

and chalet1 casa1 and calls the method chalet1.abrirVentanas (2) will run

the procedure code abrirVentanas Cchalet class and not Ccasa class.

Hello, world.

First, let's see what structure should have the typical program which

starts in any programming language that provides a first view of the

language syntax and begins transmitting a series of feelings of acceptance

or rejection by the programmer. the program simply will display the

message "Hello, world" and terminates.

Page 8: Proyecto

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 the

main () method. Classes may be compiled not have main () method, but can

not run Java interpreter initially, but they can run if called from another

running method. We will see in later chapters how creating applets is

different and does not declare this method.

Statement of the main () method:

· Public: indicates that the method main () is public and therefore can be

called from other classes. All main () method must be public to run from

the Java interpreter (JVM).

· Static: indicates that the class does not need to be instantiated use the

method that qualifies. (Not create any instance or Hello class object). It

also indicates that the method is the same for all instances that may be

created.

· Void: indicates that the main function returns no value.

· The main method must always accept, as a parameter, a vector strings

that contain the possible arguments that are passed to program on the

command 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 Types

In 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, without

the use of classes (OOP). These types are:

Byte, short, int, long, float, double, char, Boolean.

Page 9: Proyecto

Data Types reference

All other data types that are not simple, are considered benchmarks.

These guys are basically the classes, which is based programming

object oriented.

Scope of a variable

The scope of a variable is the portion of the program where the variable is

visible to the program code and, therefore, referenceable.

The scope of a variable depends on the location of the program where it is

declared, may belong to four different categories.

· Local Variable.

· Attribute.

· A method parameter.

· Parameter of an exception handler.

Local Variable

A local variable is declared within the body of a method of a class and is

visible only within that method.

Attributes

The attributes of a class are the features to be taken into account on an

object and hence its area is limited, in principle, within the class to which

characterize.

Alternative structures

Alternative structures are structures that allow you to alter the flow

a sequential program so that depending on a condition or value

of an expression, the same can be diverted in either alternative

code.

if-else

Simple:

if (expression)

Block instructions

The statement block is executed if, and only if, the expression (which must

be logic) evaluates to true, ie a certain condition is met.

Page 10: Proyecto

Switch

Simple:

switch (expression) {

case value1: instrucciones1;

case value2: instrucciones2;

...

valueN case: instruccionesN;

}

In this case, unlike the above, whether or instrucciones2 or instrucciones1

instruccionesN are formed by a single block of instructions, it is

parentizarlas required by the braces ({...}).

Loops

Loops are repeat structures. Blocks of instructions that repeat a number

of times while a condition is met or until enforcing a condition.

Loop for

for (initialization, condition, increment)

block instructions

· The initialization clause is a statement that executes a single After the

start of the loop, typically to initialize a counter.

The condition clause is a logical expression that evaluates to top each new

iteration of the loop.

The increase clause is a statement that is executed in each iteration of the

loop as if it were the last statement in the statement block.

Do-while loop.

do

block instructions

while (Expression);

In this type of loop instruction block is executed once so long less, and that

block of instruction will be executed while expression evaluates to true.

While loop

while (Expression)

block instructions

Page 11: Proyecto

As in do-while loop in the previous section, the statement block is executed

while a condition is met (while expression evaluates to true), but in this

case, the condition is checked before start first run loop, so if expression

evaluates to false in the first iteration, then the statement block will not

execute any time.

Vectors

To handle collections of objects of the same type in a single structured

vectores12 variable is used. In Java, the vectors are actually objects and

therefore 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 the

attributes and methods. The way to declare that a class inherits from

another is:

class ClassName extends NombreSuperclase

example:

Nif class extends Dni

Declares a class that inherits Nif all attributes and

Dni class methods.

Abstract

Abstract classes can not be instanciadas17. These are for declare

subclasses should override those methods that have been declared

abstract. This does not mean that all methods of an abstract class

abstractos18 should be even possible that none of them is. Even in this

latter case, the class is considered abstract and not be declared Objects

of this class.

When any of the methods of a class is declared abstract class must

abstract necessarily be, otherwise, the compiler generates a message

error.

Page 12: Proyecto