Ha, ha, that's a good one if you're being sarcastic.  If not then if an
employee is fired then you simply delete his/her instance in your code (it's
called an object's life cycle) or if you want, you can change his instance
to a person depending on the context of your system/application but you'll
have to get rid of the id attribute.  Classes and objects are not the same
thing.  This isn't a database and besides nic fuhrer says this thread of
discussion should cease.

-----Original Message-----
From: Pierre-Yves Saumont [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 17, 2001 1:46 PM
To: [EMAIL PROTECTED]
Subject: Re: Object Oriented ??


Hi,

And when the Employee get fired ? Do you change his/her class to make
him/her a Person ?

Pierre-Yves


-----Message d'origine-----
De : A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]De la part de
Thompson, Willard (GTICCC)
Envoy� : mardi 17 juillet 2001 19:20
� : [EMAIL PROTECTED]
Objet : Re: Object Oriented ??


There's plenty of books, online documentation and courses for this.  Visit:
http://java.sun.com/docs/books/tutorial/java/index.html but an example
probably won't do it for you if you're not familiar with OOP.  Nonetheless,
below is an example of a Person object and an Employee object which inherits
from Person.

public class Person
{
    private String name;
    private int age;

    public Person()
    {
        this.name = "";
        this.age = 0;
    }

    public Person(
        String name,
        int age
        )
    {
        this.name = name;
        this.age = age;
    }

    public void setName(
        String name
        )
    {
        this.name = name;
    }

    public String getName()
    {
        return this.name;
    }

    public void setAge(
        int age
        )
    {
        this.age = age;
    }

    public int getAge()
    {
        return this.age;
    }
}

class Employee extends Person
{
    private int id;

    public Employee()
    {
        this.id = 0;
        super.setName("");
        super.setAge(0);
    }

    public Employee(
        int id,
        String name,
        int age
        )
    {
        this.id = id;
        super.setName(name);
        super.setAge(age);
    }

    public void setId(
        int id
        )
    {
        this.id = id;
    }

    public int getId()
    {
        return this.id;
    }

    public int calculateSalary()
    {
        return (this.id * 10000);
    }
}

----- Original Message -----
From: "Santosh Varma" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 17, 2001 3:48 AM
Subject: Object Oriented ??

> can any one tell me what is meant by object oriented programming by a
simple
> and plain example ??
>
> regards,
>
> Santosh Varma

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to