Вы находитесь на странице: 1из 9

Computer Science III

Computer Science III

Topic 2 Problem analysis and solution design

Learning objectives
At the end of the topic you will be able to:

Represent a problem by means of programming


elements. Describe the different elements for the representation of real problems.

Derechos reservados TecMilenio, A.C.

Computer Science III

Introduction

How i H is it th that t most t of f computer programs provide us with important information? For example, how important is that I have a calendar on my phone or an alarm that goes on 30 minutes i t before b f th the h hour of fa very important appointment?

Introduction
All these applications pp arise from our needs, and from them, we face the challenge of how to translate a real problem to a representation which a computer can understand. First we could imagine an endless number of instructions consisting of zeros and ones, which is totally false. Nowadays, thanks to the simplicity offered by programming languages languages, we can represent real problems in very simple patterns that we both can understand: ourselves and computers.

Derechos reservados TecMilenio, A.C.

Computer Science III

Problem analysis and solution design

We will start by understanding the definition of an object in the Java language. An object is a unit of code that contains a series of operations that can be used by programs to perform tasks.

Features of the objects


They may be physical or conceptual. Physical objects are those we can touch touch, such as a computer computer, a television and a box. Conceptual objects are those that cannot be touched and that can only be represented by concepts such as knowledge, intelligence, etc. They have attributes such as size, name, shape, color, etc. They y may yp perform operations p (things ( g they y can do). ) The operations affect the object attributes, for example, there may be an operation attribute that changes color from green to red.

Derechos reservados TecMilenio, A.C.

Computer Science III

Example of an object
Eagle Attributes Size: medium Color: Brown and white Speed: Very fast Strategy: Agility Operations Fly Eat Hunt Guard

The operations that an object can perform are known as methods.

Example of an object
Computer Attributes tt butes Size: 15 Color: Grey Year: 2009 Type: Laptop Operations Turn on Turn off Execute program Change users

Derechos reservados TecMilenio, A.C.

Computer Science III

Escential concepts of Java programs


Each of the methods may or may not require values to specify the details of the operation to perform. Operation (Method)
Turn on Execute program

Information required (Parameter)

Does not require information Requires the name of the program to execute Requires the name of the user to Change user change Turn off Does not require information

That information required by the methods is called Parameters.


9

Classes
The classes contain the definition of the objects. To explain this better, consider a pan to bake cakes. The baking pan itself is the class and the cakes are the objects, so a class defines a specific type of object, but each object will have its own data.

10

Derechos reservados TecMilenio, A.C.

Computer Science III

Classes
Identifying the objects can help to design a class. The class is the definition of an object object. The objects are a unique instance of a class.

Classes Two objects, one class: Dog


Object Dog1 Object Dog2

Attributes Name: Sparky Color: Brown and white Breed: Not registered Size: Medium

Attributes Name: Blacky Color: Black Breed: Labrador Size: Large

Derechos reservados TecMilenio, A.C.

Computer Science III

Classes
In the example we can notice that the class Dog defines two objects, and each of them is a unique instance of the class. What is the similarity between these two objects? That they both belong to the class Dog, so they have the same attributes defined: name, color, breed and size.

Classes
If we want to design the class Soft drinks, the first thing to d i do is t to d define fi th the attributes tt ib t , those th properties ti that th t distinguish an object (soft drink) from another:

Returnable. Size of the bottle. Flavor. Content. Brand.


14

Derechos reservados TecMilenio, A.C.

Computer Science III

Classes
Once we have the attributes, we can proceed to define the methods th d , the th actions ti we can perform f with ith th the object bj t (soft ( ft drink).

Open it. Close it. Shake it. Drink it.

15

Closing arguments
An object in the Java language is a unit of code that contains a series of operations that can be used by programs to perform tasks. tasks Classes contain the definition of objects. An object consists of methods, which define the behavior of the object and of attributes or fields which define the state of the object. Starting from these definitions, we will begin to study the syntax of the Java language.
16

Derechos reservados TecMilenio, A.C.

Computer Science III

Bibliography
Fundamentals of the Java Programming Language (SL-110-SE6) http://www.sun.com/training/catalog/courses/SL-110 SE6.xml

17

Credits
Content Author Ing. Javier Castro Ruiz, MATI Academic Coordinator Lic. Nelly Maldonado Gonzlez, MEA Translating Teacher Lic. Nelda Contreras Leal, MA Instructional Designer Lic Dalila de Len Bauelos Lic. Bauelos, MTE Graphic Designer Lic. Miguel ngel Reynosa Castro, MANM

18

Derechos reservados TecMilenio, A.C.

Вам также может понравиться