0% found this document useful (0 votes)
34 views1 page

Student Example 2

The document defines a StudentExample2 class with string and integer properties for name and age. It includes setName and setAge methods that validate input for those properties, setting defaults if validation fails.

Uploaded by

SITHARTHAN V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views1 page

Student Example 2

The document defines a StudentExample2 class with string and integer properties for name and age. It includes setName and setAge methods that validate input for those properties, setting defaults if validation fails.

Uploaded by

SITHARTHAN V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

public class StudentExample2

{
string name;
integer age;
public void setAge(integer a)
{
if(a<0 || a>100)
{
age=99;
}
else
{
age=a;
}
}
public void setName(string n)
{
Pattern pat = Pattern.compile('[/d/]');
Matcher matcher = pat.matcher(n);
Boolean matches = matcher.find();
system.debug('matches '+matches);
if(matches|| n=='')
{
name='Mytutorialrack';
}
else
{
name=n;
}
}

public void display()


{
System.debug('Name '+name);
System.debug('Age '+age);

}
}

You might also like