oh sir.. im not yet on that part.. and im not yet familiar with the modifier 'protected' even with 'utility classes'
anyway ill keep that code, someday it will be usefull .
Sir when i declare 'static' in a variable or data member which is not constant ,is it not advisable? nor encouraged?
i mean static is only use for constants? for it will be a class variable or object? or for 'final' variables?
here's a sample program exercies that i've made recently ... is this not advisable?
all the data members are static...
import javax.swing.*;
public class VideoStoreMembership
{
private static String memberName;
private static String memberMiddleName;
private static String memberLastName;
private static String memberGender;
private static String memberAddress;
private static String memberContactNumber;
private static String initial;
private static String initialCapital;
private static String lowerCase;
private static String upperCase;
private static String substrings;
private static int memberAge;
public VideoStoreMembership( )
{
memberName = "";
memberMiddleName = "";
memberLastName = "";
memberGender = " ";
memberAddress = "";
memberContactNumber = "";
initial = "";
initialCapital = "";
lowerCase = "";
upperCase = "";
substrings = "";
memberAge = 0;
}
public static String setMemberFirstName( )
{
memberName = JOptionPane.showInputDialog(null,"Enter Member's Name:", "NAME", JOptionPane.INFORMATION_MESSAGE);
initial = memberName.substring(0,1);
initialCapital = initial.toUpperCase( );
substrings = memberName.substring(1);
upperCase = substrings.toUpperCase( );
lowerCase = substrings.toLowerCase( );
if(substrings == upperCase || substrings == lowerCase)
{
substrings = substrings.toLowerCase( );
}
else if(substrings != upperCase || substrings != lowerCase)
{
substrings = substrings.toLowerCase( );
}
return initialCapital + substrings;
}
public static String setMemberMiddleName( )
{
memberMiddleName = JOptionPane.showInputDialog(null, "Enter Member's Middle Name: ", "MIDDLE NAME", JOptionPane.INFORMATION_MESSAGE);
initial = memberMiddleName.substring(0,1);
initialCapital = initial.toUpperCase( );
substrings = memberMiddleName.substring(1);
upperCase = substrings.toUpperCase( );
lowerCase = substrings.toLowerCase( );
if(substrings == upperCase || substrings == lowerCase)
{
substrings = substrings.toLowerCase( );
}
else if(substrings != upperCase || substrings != lowerCase)
{
substrings = substrings.toLowerCase( );
}
return initialCapital;
}
public static String setMemberLastName( )
{
memberLastName = JOptionPane.showInputDialog(null, "Enter Member's Last Name", "LAST NAME", JOptionPane.INFORMATION_MESSAGE);
initial = memberLastName.substring(0,1);
initialCapital = initial.toUpperCase( );
substrings = memberLastName.substring(1);
upperCase = substrings.toUpperCase( );
lowerCase = substrings.toLowerCase( );
if(substrings == upperCase || substrings == lowerCase)
{
substrings = substrings.toLowerCase( );
}
else if(substrings != upperCase || substrings != lowerCase)
{
substrings = substrings.toLowerCase( );
}
return initialCapital + substrings;
}
public static String setMemberGender( )
{
memberGender = JOptionPane.showInputDialog(null, "Enter Member's Gender", "GENDER", JOptionPane.WARNING_MESSAGE);
initial = memberGender.substring(0,1);
initialCapital = initial.toUpperCase( );
substrings = memberGender.substring(1);
upperCase = substrings.toUpperCase( );
lowerCase = substrings.toLowerCase( );
if(substrings == upperCase || substrings == lowerCase)
{
substrings = substrings.toLowerCase( );
}
else if(substrings != upperCase || substrings != lowerCase)
{
substrings = substrings.toLowerCase( );
}
return initialCapital + substrings;
}
public static String setMemberAddess( )
{
memberAddress = JOptionPane.showInputDialog(null, "Enter Member's Address", "ADDRESS", JOptionPane.INFORMATION_MESSAGE);
return memberAddress;
}
public static String setMemberContactNumber( )
{
memberContactNumber = JOptionPane.showInputDialog(null, "Enter Member's Contact Number", "CONTACT NUMBER", JOptionPane.INFORMATION_MESSAGE);
return memberContactNumber;
}
public static int setMemberAge( )
{
memberAge = Integer.parseInt(JOptionPane.showInputDialog(null,"Enter Member's Age", "AGE", JOptionPane.WARNING_MESSAGE));
if(memberAge <= 12)
{
JOptionPane.showMessageDialog(null, "Only 13-yrs Old Above Can Register For A Membership", "CANNOT PROCEED", JOptionPane.WARNING_MESSAGE);
System.exit(0);
}
else if(memberAge <= 17)
{
JOptionPane.showMessageDialog(null, "You Have Restriction On Renting Video Movies", "UNDER AGE", JOptionPane.WARNING_MESSAGE);
}
else if(memberAge <= 50)
{
JOptionPane.showMessageDialog(null, "Proceed", "VALID", JOptionPane.INFORMATION_MESSAGE);
}
else if(memberAge > 50)
{
JOptionPane.showMessageDialog(null, "Validated For Discount", "SENIOR", JOptionPane.WARNING_MESSAGE);
}
return memberAge;
}
}