473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Java OO sample

Hi,

Im looking for an example of OO. The more basic the better! ;)

Cheers,
Dave
Jul 17 '05 #1
3 2511
Im looking for an example of OO. The more basic the better! ;)


Maybe i should have gone into more detail. I want to see how 2 classes can
work together. Taking advatange of get & set.

I've tried search the net for example .java files that already exsist, but
to no joy.

Regards,
Dave
Jul 17 '05 #2
Dave W wrote:
Im looking for an example of OO. The more basic the better! ;)

Maybe i should have gone into more detail. I want to see how 2 classes can
work together. Taking advatange of get & set.

I've tried search the net for example .java files that already exsist, but
to no joy.

Regards,
Dave


Many projects in a Java book or an Java program at
http://www.sourceforge.net should work.

--
Will Twentyman
email: wtwentyman at copper dot net

Jul 17 '05 #3
On Thu, 13 May 2004 15:58:38 +0100, "Dave W"
<DaveWalker*SPAM*skydivers.co.uk> wrote (more or less):
Im looking for an example of OO. The more basic the better! ;)


Maybe i should have gone into more detail. I want to see how 2 classes can
work together. Taking advatange of get & set.

I've tried search the net for example .java files that already exsist, but
to no joy.


The advantage of set and get accessor functions is that they can
control access to the variables possessed by a class.

e.g.

public class Name
{
private String firstName;
private String surname;

public void setSurname(String s)
{ surname = s;
}

public String getSurname()
{ return surname;
}

public void setFirstName(String s)
{ firstName = s;
}

public String getFirstName()
{ return firstName;
}
}

public class PatientAdmin
{
private Name aPatient;

public void enterPatientName(String name1, String name2)
{ aPatient.setSurname(name2);
aPatient.setFirstName(name1);
}
}

Which is not terribly interesting, until it comes time that you want
to incorprate some additional validation routines to the
setSurname(aString).

Making sure that every class that changes the surname does so through
the Name.setSurname(aString) method means that you only ever need to
change one piece of code, and the new validation gets used everywhere
that a surname is amended.

--
Cheers,
Euan
Gawnsoft: http://www.gawnsoft.co.sr
Symbian/Epoc wiki: http://html.dnsalias.net:1122
Smalltalk links (harvested from comp.lang.smalltalk) http://html.dnsalias.net/gawnsoft/smalltalk
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve W | last post by:
I've searched over and over again and have not been able to find a definitive answer. Basically, we have a heavily JavaScripted web site. What I was hoping to do was to start enhancing our site...
0
by: Ray Tayek | last post by:
hi, trying to convert some csv files into xsml and pulling a few hairs out :(. using the files below. a java program will parse the csv and take care of strange names and notes that line breaks in...
4
by: Dr. Laurence Leff | last post by:
I am writing a Java program to read in XML file, modify some elements slightly, and then write it out. That XML file is prepared in Docbook. It works fine, except that it is disturbing the...
7
by: Alex | last post by:
Hi all, I am trying to install a java stored procedure via the windows development centre. The linux box is running 8.1 FP4 as is the windoze platform. If I am on the linux box i can install...
4
by: Christos Kalantzis | last post by:
Hello, I am trying to get JAVA UDFs working in DB2 8.2.2. I created a class, then I compiled it using with the IBM JDK included with DB2. I put the class in the sqllib folder and created a...
1
by: Larry Menard | last post by:
Folks, I've written the world's simplest java UDF, and it is complaining that it can't load the method. The class seems OK, it's complaining about the method. The JDBC Sample UDFs (e.g.,...
0
by: rxding | last post by:
Hello, Performance reason we need to move some of our code into database. Java Store Procedure is given the first choice. However, while investigating some sample code of Java store procedure, ...
3
by: satish mullapudi | last post by:
Hi, I am using DB2 v8.2 & jdk 1.5. I have written a Hello World program in java. Now is it possible to call the HelloWorld program from a stored procedure ? If so, how? I want to catch the result...
4
by: puntino | last post by:
Hi I have created my Alarm, at compile time I don't have any problem, but at run time I receive the follo wing messages: Exception in thread "main" java.lang.NullPointerException at...
7
by: swethak | last post by:
Hi, i have a command to convert the video file into image ffmpeg -i sample.wmv -f image2 -t 0.001 -ss 3 ss.jpg i run that one in command prompt it converted the video file into...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.