2 Replies - 521 Views - Last Post: 07 October 2010 - 06:49 PM Rate Topic: -----

#1 nabeel2205  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-June 10

Need Help in File Handling

Posted 07 October 2010 - 06:22 PM

CMM - Driver Class

import java.util.*;
import java.io.*;
import java.awt.event.*;
 
public class CMM
{
		//STATIC VARIABLES
		static int num = 0, mobileServiceCounter = 0, ChargePlanCounter = 0, vasCounter=0;
		static int option;
		
		//Login variables
		static String loginName="", loginPass="";
		
		//Account variables
		static String name="", address="", age="", type="", status="", accDate="";
		
		//Services variables
		static String mobileServiceType="", mobileServiceNo="", mobileServiceIMSI="", mobileServiceStatus="", mobileServiceDate="";
		
		//Charge Plan variables
		static String chargePlanNo="", chargePlanType="";
		
		//VAS variables
		static String vasID, vasName;
		
		static Scanner inputInt = new Scanner (System.in);
		static Scanner inputString = new Scanner (System.in);
		
		static Account[] accounts = new Account[50];
		static Services[] service = new Services[50];
		static ChargePlan[] chargePlan = new ChargePlan[50];
		static VAS[] vas = new VAS[50];
		
		static Log logs = new Log();

		
		//Login Menu
		public static void LoginMenu() throws IOException
		{
			int loginOption;
			String iLoginOption;
			
			do
			{
				System.out.println("------------------------------------------------");
				System.out.println("-         Customer Management Module           -");
				System.out.println("------------------------------------------------");
				System.out.println("-                   Login                      -");
				System.out.println("------------------------------------------------");
				System.out.println("- 1.  Login                                    -");
				System.out.println("- 2.  Exit                                     -");
				System.out.println("------------------------------------------------");
				System.out.println("");
				System.out.print("Choose option -> ");
					iLoginOption = inputString.nextLine();
			} while (iLoginOption.compareTo("1")!=0 && iLoginOption.compareTo("2")!=0);
			
			loginOption = Integer.parseInt(iLoginOption);
			
			if(loginOption == 1)
			{
				Login();
			}
		}
		
		
		public static void Login() throws IOException
		{
			java.io.File loginFile = new java.io.File ("Login.txt");
			
			//Reading Login.txt file
			
			if (loginFile.exists() == true)
			{
				File fLogin = loginFile;
				
				FileInputStream fis = null;
				BufferedInputStream bis = null;
				DataInputStream dis = null;
				
				String strLine;
				
				try
				{
					fis = new FileInputStream(fLogin);	
					bis = new BufferedInputStream(fis);
					dis = new DataInputStream(bis);
					
					BufferedReader br = new BufferedReader (new InputStreamReader(fis));
					
					while((strLine = br.readLine()) != null)
					{
						StringTokenizer st = new StringTokenizer(strLine, "\t");
						
						while (st.hasMoreTokens())
						{
							loginName = st.nextToken();
							loginPass = st.nextToken();
						}
					}
					
					fis.close();
					bis.close();
					dis.close();
				}
				
				catch (FileNotFoundException e)
				{
					e.printStackTrace();
				}
				
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			
			
			//Login username & password
			String userName="", passWord="";
			System.out.print("\nEnter User Name: ");
				userName = inputString.nextLine();
			System.out.print("Enter Password: ");
				passWord = inputString.nextLine();
			
			//Checking usename & password
			if (userName.equals(loginName) && passWord.equals(loginPass))
			{
				System.out.println("\nUser Name and Password accepted");
				System.out.println("WELCOME TO CMM SYSTEM\n");
				
				Log.generateLog(0, loginName, "login", accounts);
				System.out.println("\nPress any key to continue..");
				inputString.nextLine();
				MainMenu();
			}
				
			else
			{
				System.out.println("\nInvalid Username or Password");
			}
			LoginMenu();
		}
		
	
		//Main Menu
		public static void MainMenu()
		{
			int mainMenuOption;
			String iMainMenuOption="";
			
			do
			{
				System.out.println("");
				System.out.println("------------------------------------------------");
				System.out.println("-        Customer Management Module            -");
				System.out.println("------------------------------------------------");
				System.out.println("-                Main Menu                     -");
				System.out.println("------------------------------------------------");
				System.out.println("- 1.  Account Management                       -");
				System.out.println("- 2.  Account List                             -");
				System.out.println("- 3.  Logout                                   -");
				System.out.println("------------------------------------------------");
				System.out.println("");
				System.out.print("Choose option -> ");
					iMainMenuOption = inputString.nextLine();
			} while (iMainMenuOption.compareTo("1")!=0 && iMainMenuOption.compareTo("2")!=0 && iMainMenuOption.compareTo("3")!=0);
			
			mainMenuOption = Integer.parseInt(iMainMenuOption);
			
			if (mainMenuOption == 1)
			{
				AccountMenu();
			}
			else if (mainMenuOption == 2)
			{
				AccountListMenu();
			}
			else
			{
				System.out.println("\nLogged out");
				
				Log.generateLog(0, loginName, "logout", accounts);
				
				System.out.println("\nPress Any Key to continue...");
				inputString.nextLine();
				
			}
			
		}
		
		//Account Menu
		public static void AccountMenu()
		{
			int accountMenuOption;
			String iAccountMenuOption="";
			
			do
			{
				System.out.println("");
				System.out.println("------------------------------------------------");
				System.out.println("-        Customer Management Module            -");
				System.out.println("------------------------------------------------");
				System.out.println("-            Account Management                -");
				System.out.println("------------------------------------------------");
				System.out.println("- 1.  Create Account                           -");
				System.out.println("- 2.  Edit Account                             -");
				System.out.println("- 3.  Termination                              -");
				System.out.println("- 4.  Back                                     -");
				System.out.println("------------------------------------------------");
				System.out.println("");
				System.out.print("Choose option -> ");
					iAccountMenuOption = inputString.nextLine();
			} while ( iAccountMenuOption.compareTo("1")!=0 && iAccountMenuOption.compareTo("2")!=0 && iAccountMenuOption.compareTo("3")!=0 && iAccountMenuOption.compareTo("4")!=0 );
			
			
			accountMenuOption = Integer.parseInt(iAccountMenuOption);
			if (accountMenuOption == 1)
			{
				CreateAccountMenu();
			}
			
			else if (accountMenuOption == 2)
			{
				SelectAccount();
			}
			
			else if (accountMenuOption == 3)
			{
				Termination();
			}
			
			else if (accountMenuOption == 4)
			{
				MainMenu();
			}
			
		}
		
		//Create Account Menu
		public static void CreateAccountMenu()
		{
			int typeOption;
			String iTypeOption="";
			
    		System.out.print("\nEnter Name: ");
    			name = inputString.nextLine();
    		System.out.print("Enter Address: ");
    			address = inputString.nextLine();
    		System.out.print("Age: ");
    			age = inputString.nextLine();
    		
    		do
    		{
    			System.out.println("");
				System.out.println("------------------------------------------------");
				System.out.println("-               Type of Clients                -");
				System.out.println("------------------------------------------------");
				System.out.println("- 1.  Individual                               -");
				System.out.println("- 2.  Private Organization                     -");
				System.out.println("- 3.  Government                               -");
				System.out.println("- 4.  NGO                                      -");
				System.out.println("------------------------------------------------");
				System.out.println("");
	    		System.out.print  ("Choose Type -> ");
	    			iTypeOption = inputString.nextLine();
	    			
    		}while( iTypeOption.compareTo("1")!=0 && iTypeOption.compareTo("2")!=0 && iTypeOption.compareTo("3")!=0 && iTypeOption.compareTo("4")!=0 );
    		
    		typeOption = Integer.parseInt(iTypeOption);
    		
    		if (typeOption == 1)
    		{
    			type = "Individual";
    		}
    		else if (typeOption == 2)
    		{
    			type = "Private Org.";
    		}
    		else if (typeOption == 3)
    		{
    			type = "Government";
    		}
    		else if (typeOption == 4)
    		{
    			type = "NGO";
    		}
    		
    		accounts[num] = new Account(num+1, name, address, age, type);
    		num++;
    		Log.generateLog(num-1, "account", "create", accounts);
    		
    		System.out.println("\nAccount created\n");
    		System.out.print("Press Any Key to continue...");
    			inputString.nextLine();
    		
    		AccountMenu();
		}
		
		
		//Edit Account Menu
		public static void EditAccountMenu(int iTempAccNo)
		{
			int editAccountMenuOption, fTempAccNo = iTempAccNo;
			String iEditAccountMenuOption="";
			
			do
			{
				System.out.println("");
				System.out.println("------------------------------------------------");
				System.out.println("-         Customer Management Module           -");
				System.out.println("------------------------------------------------");
				System.out.println("-                Edit Account                  -");
				System.out.println("------------------------------------------------");
				System.out.println("-                                              -");
				System.out.println("-          Account " + accounts[fTempAccNo-1].getAccNo() + " is selected               -");
				System.out.println("-                                              -");
				System.out.println("- 1.  Edit Account Info                        -");
				System.out.println("- 2.  Edit Account Services                    -");
				System.out.println("- 3.  Back                                     -");
				System.out.println("------------------------------------------------");
				System.out.println("");
				System.out.print("Choose option -> ");
					iEditAccountMenuOption = inputString.nextLine();
			} while ( iEditAccountMenuOption.compareTo("1")!=0 && iEditAccountMenuOption.compareTo("2")!=0 && iEditAccountMenuOption.compareTo("3")!=0 );
			
			editAccountMenuOption = Integer.parseInt(iEditAccountMenuOption);
			

			if (editAccountMenuOption == 1)
			{
				EditAccountInfo(fTempAccNo);
			}
			else if (editAccountMenuOption == 2)
			{
				
				if(accounts[fTempAccNo-1].getStatus().equals("Inactive"))
				{
					System.out.println("\nThis Account's status is Inactive");
					System.out.println("\nPress Any Key to continue...");
						inputString.nextLine();
					EditAccountMenu( fTempAccNo );
				}
				else
				checkMobileService(fTempAccNo);
			}
			//Back option
			else if ( editAccountMenuOption == 3 )
			{
				AccountMenu();
			}
		}
		
		
		//Termination
		public static void Termination()
		{
			int editAccountNo, tempAccNo = 0, exist = 0;
			
			AccountInfo();
			System.out.print("\nEnter the account no. to terminate -> ");
				editAccountNo = inputInt.nextInt();
			
			for(int i=0; i<num; i++)
			{
				if (editAccountNo == accounts[i].getAccNo())
				{
					exist = 1;
					tempAccNo = editAccountNo;
					break;
				}
				else exist = 0;
			}
			if ( exist == 0 )
			{
				System.out.println("Account not exist");
				Termination();
			}
			else
			{
				TerminateAccount(tempAccNo);
			}
		}
		
		//Terminate Account
		public static void TerminateAccount(int tempAccNo)
		{
			int terminateAccountOption;
			String iTerminateAccountOption="";
			
			do
			{
				System.out.println("");
				System.out.println("------------------------------------------------");
				System.out.println("-         Customer Management Module           -");
				System.out.println("------------------------------------------------");
				System.out.println("-           Terminatation Account              -");
				System.out.println("------------------------------------------------");
				System.out.println("-                                              -");
				System.out.println("- 1.  Activate Account                         -");
				System.out.println("- 2.  Deactivate Account                       -");
				System.out.println("- 3.  Back                                     -");
				System.out.println("------------------------------------------------");
				System.out.println("");
				System.out.print("Enter option -> ");
					iTerminateAccountOption = inputString.nextLine();
				System.out.println();
			} while ( iTerminateAccountOption.compareTo("1")!=0 && iTerminateAccountOption.compareTo("2")!=0 && iTerminateAccountOption.compareTo("3")!=0 );
			
			terminateAccountOption = Integer.parseInt(iTerminateAccountOption);
			
			if (terminateAccountOption == 1)
			{
				accounts[tempAccNo-1].activateAccount();
				
				Log.generateLog(tempAccNo-1, "account", "activate", accounts);
				
				inputString.nextLine();
				AccountMenu();
			}
			
			else if (terminateAccountOption == 2)
			{
				for(int t=0;t<mobileServiceCounter;t++)
				{
					if(service[t].getAccNo()==tempAccNo )
					{
						service[t].terminateStatus();
					}
				}
				accounts[tempAccNo-1].terminateAccount();
				
				Log.generateLog(tempAccNo-1, "account", "terminate", accounts);
				
				inputString.nextLine();
				AccountMenu();
			}
			
			else
				AccountMenu();
			
			
		}
		
		//Select Account
		public static void SelectAccount()
		{
			int editAccountNo, tempAccNo = 0, exist = 0;
			
			AccountInfo();
			System.out.print("\nEnter the account no. to edit: ");
				editAccountNo = inputInt.nextInt();
			
			for(int i=0; i<num; i++)
			{
				if (editAccountNo == accounts[i].getAccNo())
				{
					exist = 1;
					tempAccNo = editAccountNo;
					break;
				}
				else exist = 0;
			}
			
			if (exist == 0)
			{
				System.out.println("Account is not exist");
				SelectAccount();
			}
			else
			{
				EditAccountMenu(tempAccNo);
			}
		}
		
		//View Account Details
		public static void ViewAccountDetails( int iCounterDetails )
		{
			System.out.println("");
			System.out.println("------------------------------------------------");
			System.out.println("-         Customer Management Module           -");
			System.out.println("------------------------------------------------");
			System.out.println("-              Account Details                 -");
			System.out.println("------------------------------------------------");
			System.out.println("");
			accounts[iCounterDetails].getDetails();
		
			System.out.print("\nPress any key to continue...");
			inputString.nextLine();
			
			AccountListMenu();
		}
		
		//Edit Account Info
		public static void EditAccountInfo(int fTempAccNo)
		{
			int editAccountInfoOption;
			String iEditAccountInfoOption="";

			System.out.println("");
			System.out.println("------------------------------------------------");
			System.out.println("-         Customer Management Module           -");
			System.out.println("------------------------------------------------");
			System.out.println("-             Edit Account Info                -");
			System.out.println("------------------------------------------------");

			accounts[fTempAccNo-1].getDetails();
			
			do
			{
				System.out.println("------------------------------------------------");
				System.out.println("- 1.  Change Name                              -");
				System.out.println("- 2.  Change Address                           -");
				System.out.println("- 3.  Change Type                              -");
				System.out.println("- 4.  Change Age                               -");
				System.out.println("- 5.  Back                                     -");
				System.out.println("------------------------------------------------");
				System.out.println("");
				System.out.print( "Enter option -> ");
					iEditAccountInfoOption = inputString.nextLine();
			} while (iEditAccountInfoOption.compareTo("1")!=0 && iEditAccountInfoOption.compareTo("2")!=0 && iEditAccountInfoOption.compareTo("3")!=0 && iEditAccountInfoOption.compareTo("4")!=0 && iEditAccountInfoOption.compareTo("5")!=0);
			
			editAccountInfoOption = Integer.parseInt(iEditAccountInfoOption);
			
			if (editAccountInfoOption == 1)
			{
				//Edit and replace it with New Name
				System.out.println("Current name: " + accounts[fTempAccNo-1].getName());
				System.out.print("Enter new name: ");
					String newName = inputString.nextLine();
				accounts[fTempAccNo-1].setName(newName);
				
				System.out.println("\nThe changes has been saved");
				inputString.nextLine();
				
				Log.generateLog(fTempAccNo-1, "info - name", "edit", accounts);
				
				EditAccountInfo(fTempAccNo);
			}
			
			else if (editAccountInfoOption == 2)
			{
				//Edit and replace it with New Address
				System.out.println("\nCurrent address: " + accounts[fTempAccNo-1].getAddress());
				System.out.print("Enter new address: ");
					String newAddress = inputString.nextLine();
					accounts[fTempAccNo-1].setAddress(newAddress);
					
				System.out.println("\nThe changes has been saved");
				inputString.nextLine();
				
				Log.generateLog(fTempAccNo-1, "info - address", "edit", accounts);
				
				EditAccountInfo( fTempAccNo );
			}
			
			
			else if (editAccountInfoOption == 3)
			{
				//Edit and replace it with New Type of Clients
				int typeOption;
				String iTypeOption="";
				
				System.out.println("\nCurrent type: " + accounts[fTempAccNo-1].getType());
				System.out.println();
				
				do
	    		{
	    			System.out.println("------------------------------------------------");
					System.out.println("-         Customer Management Module           -");
					System.out.println("------------------------------------------------");
					System.out.println("-               Type of Clients                -");
					System.out.println("------------------------------------------------");
					System.out.println("- 1.  Individual                               -");
					System.out.println("- 2.  Private Organization                     -");
					System.out.println("- 3.  Government                               -");
					System.out.println("- 4.  NGO                                      -");
					System.out.println("------------------------------------------------");			
					System.out.println("");
		    		System.out.print  ("Choose Type -> ");
		    			iTypeOption = inputString.nextLine();
		    			
	    		} while (iTypeOption.compareTo("1")!=0 && iTypeOption.compareTo("2")!=0 && iTypeOption.compareTo("3")!=0 && iTypeOption.compareTo("4")!=0);
	    		
				typeOption = Integer.parseInt(iTypeOption);
				
	    		if (typeOption == 1)
	    		{
	    			type = "Individual";
	    		}
	    		else if (typeOption == 2)
	    		{
	    			type = "Private Org.";
	    		}
	    		else if (typeOption == 3)
	    		{
	    			type = "Government";
	    		}
	    		else if(typeOption == 4)
	    		{
	    			type = "NGO";
	    		}
	    		
	    		accounts[fTempAccNo-1].setType(type);
	    		
	    		System.out.println("\nThe changes has been saved");
				inputString.nextLine();
				
				Log.generateLog(fTempAccNo-1, "info - type", "edit", accounts);
				
				EditAccountInfo( fTempAccNo );
	    		
			}
			
			else if (editAccountInfoOption == 4)
			{
				//Edit and replace it with New Age
				System.out.println("\nCurrent age: " + accounts[fTempAccNo-1].getAge() );
				System.out.print("Enter new age: ");
					String newAge = inputString.nextLine();
					accounts[fTempAccNo-1].setAge( newAge );
					
				System.out.println("\nThe changes has been saved");
				inputString.nextLine();
				
				Log.generateLog(fTempAccNo-1, "info - age", "edit", accounts);
				
				EditAccountInfo( fTempAccNo );
			}
			
			
			else if (editAccountInfoOption == 5)
			{
				//Back to Previous Menu
				EditAccountMenu( fTempAccNo );
			}
		}

		//Check Mobile Services
		public static void checkMobileService(int fTempAccNo)
		{
				java.io.File msFile = new java.io.File ("MobileService.txt");
	    		
	    		// Check if the file exists or not
	    		if (mobileServiceCounter !=0)
	    		{
	    			int exist=0;
	    			
	    			for (int i=0; i<mobileServiceCounter; i++)
	    			{
	    				if (service[i].getAccNo() == fTempAccNo)
	    				{
	    					exist=1;
	    					break;
	    				}
	    				else exist=0;
	    			}
	    			if ( exist == 1 )
	    			{
	    				System.out.println("------------------------------------------------");
						System.out.println("-         Customer Management Module           -");
						System.out.println("------------------------------------------------");
						System.out.println("-               List of Services               -");
						System.out.println("------------------------------------------------");
	    				System.out.println("");
	    				System.out.println(accounts[fTempAccNo-1].getName() + "'s " + "(account no." + accounts[fTempAccNo-1].getAccNo() + ")" + " mobile service(s) list:");
	    				System.out.println("");	
	    				System.out.println("------------------------------------------------");
	    				System.out.println("- No.\t" + "Mobile Services No  " + "Type       " + "Status  -");
	    				System.out.println("------------------------------------------------");
	    				
	    				for (int i=0; i<mobileServiceCounter; i++)
	    				{
	    					if (service[i].getAccNo() == fTempAccNo)
	    					{
	    						System.out.printf("- %-6d", service[i].getSubAccountNo());
	    						System.out.printf("%-20s", service[i].getServiceNo());
	    						System.out.printf("%-9s", service[i].getServiceType());
	    						System.out.printf("%-10s-", service[i].getStatus());
	    						System.out.println("");
	    					}
	    				}
	    				System.out.println("------------------------------------------------");
	    				System.out.println("");
						chooseServiceMenu(fTempAccNo);
	    			}
	    			else
	    			{
	    				System.out.println("\nThere is no mobile services registered yet");
	    				System.out.print("\nPress Any Key to continue...");
	    					inputString.nextLine();
	    				System.out.println();
	    				registerMobileServiceMenu(fTempAccNo);
	    			}
	    			
	    		}
	    		else
	    		{
	    			System.out.println("\nThere is no mobile services registered yet");
	    			System.out.print("\nPress Any Key to continue...");
	    				inputString.nextLine();
	    			
	    			registerMobileServiceMenu(fTempAccNo);
	    		}
			
			
		}
		
		//Choose Service Menu
		public static void chooseServiceMenu(int fTempAccNo)
		{
			int editServiceOpt;
			String iEditServiceOpt="";
			
			do
			{
				System.out.println("------------------------------------------------");
				System.out.println("- 1.  Select Service Number                    -");
				System.out.println("- 2.  Add New Service                          -");
				System.out.println("- 3.  Back                                     -");
				System.out.println("------------------------------------------------");	
				System.out.print ("\nChoose option -> ");
					iEditServiceOpt = inputString.nextLine();
			} while (iEditServiceOpt.compareTo("1")!=0 && iEditServiceOpt.compareTo("2")!=0 && iEditServiceOpt.compareTo("3")!=0);
			
			editServiceOpt = Integer.parseInt (iEditServiceOpt);
			
			if(editServiceOpt == 1)
			{
				selectService(fTempAccNo);
			}
			if( editServiceOpt == 2)
			{
				registerMobileServiceMenu( fTempAccNo );
			}
			else if ( editServiceOpt == 3 )  
			{
				EditAccountMenu( fTempAccNo );
			}
		}
		
		//Select Services
		public static void selectService(int fTempAccNo)
		{
			int editServiceNo, tempServiceNo = 0, exist = 0;
			
			System.out.print("\nEnter the account no. to edit -> ");
				editServiceNo = inputInt.nextInt();
			
			for(int i=0; i<mobileServiceCounter; i++)
			{
				if(service[i].getAccNo() == fTempAccNo)
				{
					if(service[i].getSubAccountNo() == editServiceNo)
					{
						exist = 1;
						tempServiceNo = editServiceNo;
						break;
					}
					else exist = 0;
				}
			}
			if (exist == 0)
			{
				System.out.println("The account is not exist");
				chooseServiceMenu(fTempAccNo);
			}
			else
			{
				editAccountServicesMenu(fTempAccNo, tempServiceNo);
			}
		}
		
		//Register Mobile Service Menu
		public static void registerMobileServiceMenu(int fTempAccNo)
		{
			int msCounter = 0, registerTypeOption;
			String type="", iRegisterTypeOption="";
			
			do
			{
				System.out.println("------------------------------------------------");
				System.out.println("-         Customer Management Module           -");
				System.out.println("------------------------------------------------");
				System.out.println("-          Type of Mobile Services             -");
				System.out.println("------------------------------------------------");
				System.out.println("- 1.  Voice                                    -");
				System.out.println("- 2.  Data                                     -");
				System.out.println("- 3.  Back                                     -");
				System.out.println("------------------------------------------------");	
				System.out.println("");
				System.out.print("Choose option -> ");
					iRegisterTypeOption = inputString.nextLine();
			} while (iRegisterTypeOption.compareTo("1")!=0 && iRegisterTypeOption.compareTo("2")!=0 && iRegisterTypeOption.compareTo("3")!=0);
			
			registerTypeOption = Integer.parseInt (iRegisterTypeOption);
			
			if (registerTypeOption == 1)
			{	
				type = "Voice";
			}
			else if (registerTypeOption == 2)
			{
				type = "Data";
			}
			else if (registerTypeOption == 3)
			{
				checkMobileService(fTempAccNo);
			}
			
			for(int i=0 ; i<mobileServiceCounter ; i++)
			{
				if(service[i].getAccNo() == fTempAccNo)
				{
					msCounter = service[i].getSubAccountNo();
				}
			}
			
			service[mobileServiceCounter] = new Services (fTempAccNo, msCounter+1, type);
				
			Log.generateLog(fTempAccNo-1, "mobile service", "add", accounts);
			
			service[mobileServiceCounter].generateIMSI();
			service[mobileServiceCounter].generateServiceNo();
			
			mobileServiceCounter++;
			
			if (type.equals("Voice"))
			{
				voiceChargePlanMenu(fTempAccNo, msCounter+1);
			}
			else if (type.equals("Data"))
			{
				dataChargePlanMenu(fTempAccNo, msCounter+1);
			}
		}
		
		
		//Voice Charge Plan
		public static void voiceChargePlanMenu(int fTempAccNo, int fTempServiceNo)
		{
			String voiceChargeOption="", iPlanID="", iPlanType="VOICE";
			int iVoiceChargeOption;
			
			do
			{
				ChargePlan.displayChargeVoicePlan();
				System.out.println();
				System.out.print("Enter the no. of Value Plan ->");
					voiceChargeOption = inputString.nextLine();
			} while (voiceChargeOption.compareTo("1")!=0 && voiceChargeOption.compareTo("2") !=0 && voiceChargeOption.compareTo("3") !=0 && voiceChargeOption.compareTo("4") !=0 && voiceChargeOption.compareTo("5") !=0 && voiceChargeOption.compareTo("6") !=0);
			iVoiceChargeOption = Integer.parseInt(voiceChargeOption);
			
			if(iVoiceChargeOption == 6)
			{
				checkMobileService(fTempAccNo);
			}
			else
			{
			chargePlan[ChargePlanCounter] = new ChargePlan(iVoiceChargeOption, fTempAccNo, fTempServiceNo, iPlanType);
			ChargePlanCounter++;
			
			System.out.println("Charge plan saved");
			System.out.println("\nPress Any Key to continue...");
			inputString.nextLine();
			
			checkMobileService(fTempAccNo);
			}
		}
		
		//Data Charge Plan
		public static void dataChargePlanMenu(int fTempAccNo, int fTempServiceNo)
		{
			String voiceChargeOption="", iPlanID="", iPlanType="DATA";
			int iVoiceChargeOption;
			
			do
			{
				ChargePlan.displayChargeDataPlan();
				System.out.println();
				System.out.print("Enter the no. of Data Plan ->");
					voiceChargeOption = inputString.nextLine();
			} while (voiceChargeOption.compareTo("1")!=0 && voiceChargeOption.compareTo("2") !=0  && voiceChargeOption.compareTo("3") !=0 && voiceChargeOption.compareTo("4") !=0);
			iVoiceChargeOption = Integer.parseInt(voiceChargeOption);
			
			if(iVoiceChargeOption == 4)
			{
				checkMobileService(fTempAccNo);
			}
			else
			{
			chargePlan[ChargePlanCounter] = new ChargePlan(iVoiceChargeOption, fTempAccNo, fTempServiceNo, iPlanType);
			ChargePlanCounter++;
			
			System.out.println("Charge plan saved");
			System.out.println("\nPress Any Key to continue...");
				inputString.nextLine();
				
			checkMobileService(fTempAccNo);
			}
		}
		
		//Edit Account Services Menu
		public static void editAccountServicesMenu(int fTempAccNo, int fTempServiceNo)
		{
			int editAccountOption;
			String tempServNo ="", tempStatus="", tempType="", iEditAccountOption="", tempCharge="", tempDate="";
			
			for(int i=0; i<mobileServiceCounter; i++)
			{
				if(service[i].getAccNo() == fTempAccNo )
				{
					if(service[i].getSubAccountNo() == fTempServiceNo)
					{
						tempServNo = service[i].getServiceNo();
						tempStatus = service[i].getStatus();
						tempType = service[i].getServiceType();
						tempDate = service[i].getCreationDate();
						break;
					}
				}
			}
			
			for(int i=0;i<ChargePlanCounter;i++)
			{
				if(chargePlan[i].getAccNo() == fTempAccNo && chargePlan[i].getSubAccountNo() == fTempServiceNo)
				{
					tempCharge = chargePlan[i].getPlanName();
				}
			}
			
			do
			{
				System.out.println("");
				System.out.println("------------------------------------------------");
				System.out.println("-         Customer Management Module           -");
				System.out.println("------------------------------------------------");
				System.out.println("-           Edit Account Services              -");
				System.out.println("------------------------------------------------");
				System.out.println("-                                              -");
				System.out.println("Account no." + accounts[fTempAccNo-1].getAccNo() + ", " +
						accounts[fTempAccNo-1].getName());
				System.out.println("------------------------------------------------");
				System.out.println("- Service Number : " + tempServNo + "    	       -");
				System.out.println("- Type           : " + tempType + "    		       -");
				System.out.println("- Status         : " + tempStatus + "    		       -");
				System.out.println("- Date Created   : " + tempDate + "    	       -");
				System.out.println("- Charge Plan    : " + tempCharge + "    		       -");
				System.out.println("------------------------------------------------");
				
				System.out.println("\nList of VAS");
				System.out.println();
				System.out.println("------------------------------------------------");
				System.out.println("-    VAS Code   -            VAS NAME          -");
				System.out.println("------------------------------------------------");
				int tempOpt=0;
				String space="-";
				for (int i=0; i<vasCounter; i++)
				{	
					
					
					if (vas[i].getCode().compareTo("") != 0)
					{
						if (vas[i].getAccNo()==fTempAccNo && vas[i].getSubAccountNo()==fTempServiceNo)
						{
					
							System.out.printf("-    %-11s- %-28s -\n", vas[i].getCode(), vas[i].getVASName());
							tempOpt = 1;
						}
					}				
				}
				
				if (tempOpt == 0)
				{
					System.out.printf("|     %-11s|\t\t%-11s|\n", space, space);
				}
				
				System.out.println("------------------------------------------------");
				System.out.println("");
				System.out.println("------------------------------------------------");
				System.out.println("- 1.  Activate                                 -");
				System.out.println("- 2.  Deactivate                               -");
				System.out.println("- 3.  Change Charge Plan                       -");
				System.out.println("- 4.  Add VAS                                  -");
				System.out.println("- 5.  Delete VAS                               -");
				System.out.println("- 6.  Back                                     -");
				System.out.println("------------------------------------------------");	
				System.out.println("");
				System.out.print("Choose option -> ");	
					iEditAccountOption = inputString.nextLine();
			}while (iEditAccountOption.compareTo("1")!=0 && iEditAccountOption.compareTo("2")!=0 && iEditAccountOption.compareTo("3")!=0 && iEditAccountOption.compareTo("4")!=0 && iEditAccountOption.compareTo("5")!=0 && iEditAccountOption.compareTo("6")!=0);
			
			editAccountOption = Integer.parseInt (iEditAccountOption);
			
			if(editAccountOption == 1)
			{
				activateService(fTempAccNo, fTempServiceNo);
			}
			else if (editAccountOption == 2)
			{
				deactivateService( fTempAccNo, fTempServiceNo);
			}
			else if (editAccountOption == 3)
			{
				changeChargePlan( fTempAccNo, fTempServiceNo);
			}
			else if (editAccountOption == 4)
			{
				addVAS( fTempAccNo, fTempServiceNo);
			}
			else if (editAccountOption == 5)
			{
				deleteVAS( fTempAccNo, fTempServiceNo);
			}
			else if (editAccountOption == 6)
			{
				checkMobileService(fTempAccNo);
			}	
		}
		
		//Activate Service
		public static void activateService(int yTempAccNo, int yTempServiceNo)
		{
			for(int i=0; i<mobileServiceCounter; i++)
			{
				if(service[i].getAccNo() == yTempAccNo)
				{
					if(service[i].getSubAccountNo() == yTempServiceNo)
					{
						service[i].activateService();
						Log.generateLog(yTempAccNo-1, "mobile service", "activate", accounts);
						System.out.print("Press Any Key to continue...");
							inputString.nextLine();
						editAccountServicesMenu(yTempAccNo, yTempServiceNo);
						break;
					}
				}
			}
		}
		
		//Deactivate Service
		public static void deactivateService(int yTempAccNo, int yTempServiceNo)
		{
			for (int i=0; i<mobileServiceCounter; i++)
			{
				if (service[i].getAccNo() == yTempAccNo)
				{
					if(service[i].getSubAccountNo() == yTempServiceNo)
					{
						service[i].deactivateService();
						
						Log.generateLog(yTempAccNo-1, "mobile service", "terminate", accounts);
						System.out.print("Press Any Key to continue...");
						inputString.nextLine();
						editAccountServicesMenu(yTempAccNo, yTempServiceNo);
						break;
					}
				}
			}
		}
		
		//Change Charge Plan
		public static void changeChargePlan(int fTempAccNo, int fTempServiceNo)
		{
			String voiceChargeOption="", iPlanID="", iPlanType="";
			int iVoiceChargeOption;

			for(int i=0; i<ChargePlanCounter; i++)
			{
				if(chargePlan[i].getAccNo()==fTempAccNo)
				{
					if(chargePlan[i].getSubAccountNo()==fTempServiceNo)
					{
						iPlanType = chargePlan[i].getPlanType();
					}
				}
			}
			
			if(iPlanType.equals("VOICE"))
			{
				do
				{
					System.out.println("");
					ChargePlan.displayChargeVoicePlan();
					System.out.println("");
					System.out.print("Enter the no. of Value Plan -> ");
						voiceChargeOption = inputString.nextLine();
				} while (voiceChargeOption.compareTo("1")!=0 && voiceChargeOption.compareTo("2") !=0 && voiceChargeOption.compareTo("3") !=0 && voiceChargeOption.compareTo("4") !=0 && voiceChargeOption.compareTo("5") !=0 && voiceChargeOption.compareTo("6") !=0);
				iVoiceChargeOption = Integer.parseInt(voiceChargeOption);
				
				if(iVoiceChargeOption == 1)
				{
					iPlanID = "VP01";
				}
				else if(iVoiceChargeOption == 2)
				{
					iPlanID = "VP02";
				}
				else if(iVoiceChargeOption == 3)
				{
					iPlanID = "VP03";
				}
				else if(iVoiceChargeOption == 4)
				{
					iPlanID = "VP04";
				}
				else if(iVoiceChargeOption == 5)
				{
					iPlanID = "VP05";
				}
			}
			else if(iPlanType.equals("DATA"))
			{
				do
				{
					System.out.println("");
					ChargePlan.displayChargeDataPlan();
					System.out.println("");
					System.out.print("Enter the no of Data Plan ->");
						voiceChargeOption = inputString.nextLine();
				} while (voiceChargeOption.compareTo("1")!=0 && voiceChargeOption.compareTo("2") !=0  && voiceChargeOption.compareTo("4") !=0);
				iVoiceChargeOption = Integer.parseInt(voiceChargeOption);
				
				if(iVoiceChargeOption == 1)
				{
					iPlanID = "DP01";
				}
				else if(iVoiceChargeOption == 2)
				{
					iPlanID = "DP02";
				}
				else if(iVoiceChargeOption == 3)
				{
					iPlanID = "DP03";
				}
			}
			
			for(int i=0; i<ChargePlanCounter; i++)
			{
				if(chargePlan[i].getAccNo() == fTempAccNo)
				{
					if(chargePlan[i].getSubAccountNo() == fTempServiceNo)
					{
						chargePlan[i].changePlanID(iPlanID);
					}
				}
			}
			Log.generateLog(fTempAccNo-1, "charge plan", "edit", accounts);
			System.out.println("Charge Plan changed.");
			System.out.print("Press Any Key to continue...");
			inputString.nextLine();
			editAccountServicesMenu( fTempAccNo, fTempServiceNo );
		}
		
		//Add VAS
		public static void addVAS(int fTempAccNo, int fTempServiceNo)
		{
			String vasOption="", iPlanType="", code="";
			int vasOption1;
			int exist = 0;
			
			for(int i=0; i<ChargePlanCounter; i++)
			{
				if(chargePlan[i].getAccNo() == fTempAccNo)
				{
					if(chargePlan[i].getSubAccountNo() == fTempServiceNo)
					{
						iPlanType = chargePlan[i].getPlanType();
					}
				}
			}
			
			if(iPlanType.equals("VOICE"))
			{
				do
				{
					System.out.println();
					VAS.displayVoiceTypeVAS();
					System.out.println();
					System.out.print("Enter the no. of Value Plan -> ");
						vasOption = inputString.nextLine();
				} while (vasOption.compareTo("1")!=0 && vasOption.compareTo("2") !=0 && vasOption.compareTo("3") !=0 && vasOption.compareTo("4") !=0);
				vasOption1 = Integer.parseInt(vasOption);
				
				if(vasOption1 == 4)
				{
					editAccountServicesMenu(fTempAccNo, fTempServiceNo);
				}
				else
				{
					code = VAS.checkVas(vasOption1, iPlanType);
					for(int i=0 ; i<vasCounter ; i++)
					{
						if (vas[i].getAccNo() == fTempAccNo && vas[i].getSubAccountNo() == fTempServiceNo)
						{
								if(vas[i].getCode().equals(code))
								{
									exist=1;
									break;
								}
						}
					}
					
					if(exist==1)
					{
						System.out.println("This VAS already exist in this particular mobile service.");
						System.out.print("Press Any Key to continue..");
							inputString.nextLine();
						editAccountServicesMenu(fTempAccNo, fTempServiceNo);
					}
					else
					{
						vas[vasCounter] = new VAS(vasOption1, fTempAccNo, fTempServiceNo, iPlanType);
						vasCounter++;
						
						Log.generateLog(fTempAccNo-1, "VAS", "add", accounts);
						
						System.out.println("VAS added.");
						System.out.print("Press Any Key to continue...");
						inputString.nextLine();
						
						editAccountServicesMenu(fTempAccNo, fTempServiceNo);
					}
				}
				
			}
			else if(iPlanType.equals("DATA"))
			{
				do
				{
					System.out.println();
					VAS.displayDataTypeVAS();
					System.out.println();
					System.out.print("Enter the no. of Data Plan -> ");
						vasOption = inputString.nextLine();
				} while (vasOption.compareTo("1")!=0 && vasOption.compareTo("2") !=0 && vasOption.compareTo("3") !=0 && vasOption.compareTo("4") !=0);
				vasOption1 = Integer.parseInt(vasOption);
				
				if(vasOption1 == 4)
				{
					editAccountServicesMenu(fTempAccNo, fTempServiceNo);
				}
				else
				{
				vas[vasCounter] = new VAS(vasOption1, fTempAccNo, fTempServiceNo, iPlanType);
				vasCounter++;
				
				Log.generateLog(fTempAccNo-1, "VAS", "add", accounts);
				
				System.out.println("VAS added.");
				System.out.println("Press Any Key to continue...");
				inputString.nextLine();
				
				editAccountServicesMenu(fTempAccNo, fTempServiceNo);
				}
			}
			
			

		}
		
		//Delete VAS
		public static void deleteVAS(int fTempAccNo, int fTempServiceNo)
		{
			String vasCodeOption, iVAS;
			int tempOpt=0;
			
			String tempServNo ="", tempStatus="", tempType="";
			
			for(int i=0; i<mobileServiceCounter; i++)
			{
				if(service[i].getAccNo() == fTempAccNo)
				{
					if(service[i].getSubAccountNo() == fTempServiceNo)
					{
						tempServNo = service[i].getServiceNo();
						tempStatus = service[i].getStatus();
						tempType = service[i].getServiceType();
						break;
					}
				}
			}
			
		
			System.out.println("");			
			System.out.println("------------------------------------------------");
			System.out.println("-         Customer Management Module           -");
			System.out.println("------------------------------------------------");
			System.out.println("-           Customer Information               -");
			System.out.println("------------------------------------------------");
			System.out.println("-                                              -");
			System.out.println("Account no." + accounts[fTempAccNo-1].getAccNo() + ", " +
					accounts[fTempAccNo-1].getName());
			System.out.println("------------------------------------------------");
			System.out.println("Service Number : " + tempServNo + "    	       -");
			System.out.println("Type           : " + tempType + "    		       -");
			System.out.println("Status         : " + tempStatus + "    		       -");
			System.out.println("------------------------------------------------");
			
			System.out.println("\nList of VAS");
			System.out.println("");
			System.out.println("------------------------------------------------");
			System.out.println("-    VAS Code   -            VAS NAME          -");
			System.out.println("------------------------------------------------");
			int tempOpt1=0;
			String space="-";
			for (int i=0; i<vasCounter; i++)
			{	
				if (vas[i].getCode().compareTo("") != 0)
				{
					if (vas[i].getAccNo()==fTempAccNo && vas[i].getSubAccountNo()==fTempServiceNo)
					{
						System.out.printf("-    %-11s- %-28s -\n", vas[i].getCode(), vas[i].getVASName());
						tempOpt1 = 1;
					}
				}				
			}
			
			if (tempOpt1 == 0)
			{
				System.out.printf("|     %-11s|\t\t%-11s|\n", space, space);
			}
			
			System.out.println("------------------------------------------------");
		
			System.out.print("Enter the VAS code you want to remove: ");
				vasCodeOption = inputString.nextLine();
				iVAS = vasCodeOption.toUpperCase();
			
			for (int i=0; i<vasCounter; i++)
			{
				if (vas[i].getAccNo() == fTempAccNo && vas[i].getSubAccountNo() == fTempServiceNo)
				{
					if (iVAS.equals(vas[i].getCode()))
					{
						vas[i].deleteVASCode();
						tempOpt = 1;
						break;
					}
				}
			}
			
			if (tempOpt == 0)
			{
				System.out.println("The VAS code is not available\n");
			}
			else
			{
				System.out.println("VAS has been deleted");
				Log.generateLog(fTempAccNo-1, "VAS", "remove", accounts);
			}
			
			System.out.print("\nPress Any Key to continue...");
				inputString.nextLine();
				
			editAccountServicesMenu(fTempAccNo, fTempServiceNo);
		}
		
		public static void selectAccountDetails()
		{
			int editAccountNo=0, exist = 0, counterDetails=0;
			
			AccountInfo();
			
			System.out.print("\nEnter the account no. -> ");
				editAccountNo = inputInt.nextInt();
			
			
		
			for(int i=0; i<num; i++)
			{
				if (editAccountNo == accounts[i].getAccNo())
				{
					exist = 1;
					counterDetails = i;
					break;
				}
				else exist = 0;
			}
			if (exist == 0)
			{
				System.out.println("\nThe account is no exist");
				System.out.print("Press Any Key to continue...");
				inputString.nextLine();
				AccountListMenu();
			}
			else
			{
				ViewAccountDetails(counterDetails);
			}
			
			
		}
		
		public static void selectAccountDetailsMenu()
		{
			int editAccountInfoOption;
			String iEditAccountInfoOption="";
			
			System.out.println("");
			do
			{
				System.out.println();
				AccountInfo();
				System.out.println("");
				System.out.println("------------------------------------------------");
				System.out.println("- 1.  Select Account                           -");
				System.out.println("- 2.  Back                                     -");
				System.out.println("------------------------------------------------");
				System.out.print ("\nChoose option -> ");
					iEditAccountInfoOption = inputString.nextLine();
			} while (iEditAccountInfoOption.compareTo("1")!=0 && iEditAccountInfoOption.compareTo("2")!=0);
			
			editAccountInfoOption = Integer.parseInt (iEditAccountInfoOption);
			
			if (editAccountInfoOption == 1)
			{
				selectAccountDetails();
			}
			
			else if (editAccountInfoOption == 2)
			{
				AccountListMenu();
			}
		}
		
		//Account List Menu
		public static void AccountListMenu()
		{
			int accountListMenuOption;
			String iAccountListMenuOption="";
			
			do
			{
				System.out.println("");
				System.out.println("------------------------------------------------");
				System.out.println("-         Customer Management Module           -");
				System.out.println("------------------------------------------------");
				System.out.println("-                 Account List                 -");
				System.out.println("------------------------------------------------");
				System.out.println("- 1.  View Accounts                            -");
				System.out.println("- 2.  View Details                             -");
				System.out.println("- 3.  Back                                     -");
				System.out.println("------------------------------------------------");	
				System.out.println("");
				System.out.print("Choose option -> ");
					iAccountListMenuOption = inputString.nextLine();
			} while ( iAccountListMenuOption.compareTo("1")!=0 && iAccountListMenuOption.compareTo("2")!=0 && iAccountListMenuOption.compareTo("3")!=0 );
			
			accountListMenuOption = Integer.parseInt (iAccountListMenuOption);
			
			if (accountListMenuOption == 1)
			{
				if (num == 0)
				{
					System.out.println("\nCurrently there's no customer");
					AccountListMenu();
				}
				else 
				{
					viewAccount();
				}
			}
			
			else if (accountListMenuOption == 2)
			{
				if (num == 0)
				{
					System.out.println("\nCurrently there's no customer");
					AccountListMenu();
				}
				else
				{
					selectAccountDetails();
				}
			}
			
			else if (accountListMenuOption == 3)
			{
				MainMenu();
			}
		}	
			
		//View Account
		public static void viewAccount()
		{
			AccountInfo();
			System.out.print ("Press Any Key to continue...");
			inputString.nextLine();
			AccountListMenu();
		}
		
		//Account Info
		public static void AccountInfo()
		{
			System.out.println();
			System.out.println("------------------------    CUSTOMER INFORMATION    -------------------------\n");
			System.out.println("Acc No.   " + "NAME\t\t  " + "Address\t      " + "Age   " + "Type\t  " + "Status");
	    	for ( int i=0; i<num; i++)
			{
				accounts[i].getAccountInfo();
			}
		}
	
	
	


    public static void main( String[] args ) throws IOException
    {
    	int accNo = 1, nom = 1;
    	
    	/* --------------------------- READING FILE ------------------------------ */
    	
    		java.io.File custFile = new java.io.File ("CustomerInfo.txt");
    		java.io.File msFile = new java.io.File ("MobileServiceInfo.txt");
    		java.io.File cpFile = new java.io.File ("ChargePlanInfo.txt");
    		java.io.File vasFile = new java.io.File ("VASInfo.txt");
    		
    		/* ====================== READ CustomerInfo.txt FILE =================== */
    		if (custFile.exists() == true)
    		{
    			File file = custFile;
    			
    			FileInputStream fis = null;
    			BufferedInputStream bis = null;
    			DataInputStream dis = null;
    			
    			String strLine, iAccNo="";
    			
    			try
    			{
    				fis = new FileInputStream (file);
    				
    				//Here is BufferedInputStream added for fast reading
	 				bis = new BufferedInputStream (fis);
	 				dis = new DataInputStream (bis);
	 				
	 				//New Buffer Reader
	 				BufferedReader br = new BufferedReader(new InputStreamReader(fis));
	 				
	 				while ((strLine = br.readLine()) != null)
	 				{
	 					StringTokenizer st = new StringTokenizer(strLine, "\t");
	 					
	 					while (st.hasMoreTokens())
	 					{
	 						iAccNo = st.nextToken();
	 						name = st.nextToken();
	 						address = st.nextToken();
	 						age = st.nextToken();
	 						type = st.nextToken();
	 						status = st.nextToken();
	 						accDate = st.nextToken();
	 					}
	 					
	 					accNo = Integer.parseInt(iAccNo);
	 					
	 					accounts[num] = new Account(accNo, name, address, age, type, status, accDate);
	 					num++;
	 				}
	 				
	 				fis.close();
	 				bis.close();
	 				dis.close();
    			}
    			
    			catch (FileNotFoundException e)
 				{
	 				e.printStackTrace();
	 			}
	 			
	 			catch (IOException e)
	 			{
	 				e.printStackTrace();
	 			}
    		}
    		/* ============================================================ */
    		
    		/* ==================== READ MobileServiceInfo.txt FILE ===================== */
    		
    		if (msFile.exists() == true)
    		{
    			File file = msFile;
    			
    			FileInputStream fis = null;
    			BufferedInputStream bis = null;
    			DataInputStream dis = null;
    			
    			String strLine, iAccNo="", xNom ="";
    			
    			try
    			{
    				fis = new FileInputStream (file);
    				
    				//Here is BufferedInputStream added for fast reading
	 				bis = new BufferedInputStream (fis);
	 				dis = new DataInputStream (bis);
	 				
	 				//New Buffer Reader
	 				BufferedReader br = new BufferedReader(new InputStreamReader(fis));
	 				
	 				while ((strLine = br.readLine()) != null)
	 				{
	 					StringTokenizer st = new StringTokenizer(strLine, "\t");
	 					
	 					while (st.hasMoreTokens())
	 					{
	 					
	 						iAccNo = st.nextToken();
	 						xNom = st.nextToken();
	 						mobileServiceType = st.nextToken();
	 						mobileServiceNo = st.nextToken();
	 						mobileServiceIMSI = st.nextToken();
	 						mobileServiceStatus = st.nextToken();
	 						mobileServiceDate = st.nextToken();
	 					}
	 					
	 					accNo = Integer.parseInt(iAccNo);
	 					nom = Integer.parseInt(xNom);
	 					
	 					service[mobileServiceCounter] = new Services(accNo, nom, mobileServiceType, mobileServiceNo, mobileServiceIMSI, mobileServiceStatus, mobileServiceDate);
	 					mobileServiceCounter++;
	 				}
	 				
	 				fis.close();
	 				bis.close();
	 				dis.close();
    			}
    			
    			catch (FileNotFoundException e)
 				{
	 				e.printStackTrace();
	 			}
	 			
	 			catch (IOException e)
	 			{
	 				e.printStackTrace();
	 			}
    		}
    		
    		/* ================================================================ */
    		
    		
    		/* ==================== READ ChargePlanInfo.txt FILE ===================== */
    		
    		if (cpFile.exists() == true)
    		{
    			File file = cpFile;
    			
    			FileInputStream fis = null;
    			BufferedInputStream bis = null;
    			DataInputStream dis = null;
    			
    			String strLine, wAccNo="", wNom ="";
    			
    			try
    			{
    				fis = new FileInputStream (file);
    				
    				//Here is BufferedInputStream added for fast reading
	 				bis = new BufferedInputStream (fis);
	 				dis = new DataInputStream (bis);
	 				
	 				//New Buffer Reader
	 				BufferedReader br = new BufferedReader(new InputStreamReader(fis));
	 				
	 				while ((strLine = br.readLine()) != null)
	 				{
	 					StringTokenizer st = new StringTokenizer( strLine, "\t");
	 					
	 					while (st.hasMoreTokens())
	 					{
	 						wAccNo = st.nextToken();
	 						wNom = st.nextToken();
	 						chargePlanNo = st.nextToken();
	 						chargePlanType = st.nextToken();
	 					}
	 					
	 					accNo = Integer.parseInt(wAccNo);
	 					nom = Integer.parseInt(wNom);
	 					
	 					chargePlan[ChargePlanCounter] = new ChargePlan(accNo, nom, chargePlanNo, chargePlanType);
	 					ChargePlanCounter++;
	 				}
	 				
	 				fis.close();
	 				bis.close();
	 				dis.close();
    			}
    			
    			catch (FileNotFoundException e)
 				{
	 				e.printStackTrace();
	 			}
	 			
	 			catch (IOException e)
	 			{
	 				e.printStackTrace();
	 			}
    		}
    		
    		/* ================================================================ */
    		
    		
			/* ==================== READ VASInfo.txt FILE ===================== */
    		
    		if (vasFile.exists() == true)
    		{
    			File file = vasFile;
    			
    			FileInputStream fis = null;
    			BufferedInputStream bis = null;
    			DataInputStream dis = null;
    			
    			String strLine, vAccNo="", vNom ="", vVas="", vType="";
    			
    			try
    			{
    				fis = new FileInputStream (file);
    				
    				//Here is BufferedInputStream added for fast reading
	 				bis = new BufferedInputStream (fis);
	 				dis = new DataInputStream (bis);
	 				
	 				//New Buffer Reader
	 				BufferedReader br = new BufferedReader(new InputStreamReader(fis));
	 				
	 				while ((strLine = br.readLine()) != null)
	 				{
	 					StringTokenizer st = new StringTokenizer(strLine, "\t");
	 					
	 					while (st.hasMoreTokens())
	 					{
	 						vAccNo = st.nextToken();
	 						vNom = st.nextToken();
	 						vVas = st.nextToken();
	 						vType = st.nextToken();
	 					}
	 					
	 					accNo = Integer.parseInt(vAccNo);
 						nom = Integer.parseInt(vNom);
 						vas[vasCounter] = new VAS(accNo, nom, vVas, vType);
 						vasCounter++;
	 				}
	 				
	 				fis.close();
	 				bis.close();
	 				dis.close();
    			}
    			
    			catch (FileNotFoundException e)
 				{
	 				e.printStackTrace();
	 			}
	 			
	 			catch (IOException e)
	 			{
	 				e.printStackTrace();
	 			}
    		}
    		
    		/* ================================================================ */
    		
    	
    	/* ----------------------------------------------------------------------- */

    		
    	LoginMenu();
    	
    	
    	/* --------------------------------- WRITE TO TEXT FILE ------------------------------------- */	
    	
    	/* ---------------------------------------------------------------------- */
    	Writer writer = null;
		File file = new File("CustomerInfo.txt");
		PrintWriter out = new PrintWriter (file);
		
		for (int i=0; i<num; i++)
		{
			out.print(accounts[i].getAccNo() + "\t");
    		out.print(accounts[i].getName() + "\t");
			out.print(accounts[i].getAddress() + "\t");
			out.print(accounts[i].getAge() + "\t");
			out.print(accounts[i].getType() + "\t");
			out.print(accounts[i].getStatus() + "\t");
			out.print(accounts[i].getCreationDate());
			out.println("");
		}
		
		out.close();
		/* ---------------------------------------------------------------------- */
			
		/* ---------------------------------------------------------------------- */
			
		Writer writerMS = null;
		File writeMSFile = new File("MobileServiceInfo.txt");
		PrintWriter outMS = new PrintWriter (writeMSFile);
		
		for (int i=0; i<mobileServiceCounter; i++)
		{
			outMS.print(service[i].getAccNo() + "\t" );
			outMS.print(service[i].getSubAccountNo() + "\t" );
			outMS.print(service[i].getServiceType() + "\t");
			outMS.print(service[i].getServiceNo() + "\t");
			outMS.print(service[i].getIMSI() + "\t");
			outMS.print(service[i].getStatus() + "\t");
			outMS.print(service[i].getCreationDate());
			outMS.println("");
		}
		
		outMS.close();
		
		/* ---------------------------------------------------------------------- */
		
		/* ---------------------------------------------------------------------- */
		
		Writer writerCP = null;
		File writeCPFile = new File("ChargePlanInfo.txt");
		PrintWriter outCP = new PrintWriter (writeCPFile);
		
		for (int i=0; i<ChargePlanCounter; i++)
		{
			outCP.print(chargePlan[i].getAccNo() + "\t" );
			outCP.print(chargePlan[i].getSubAccountNo() + "\t" );
			outCP.print(chargePlan[i].getPlanID() + "\t");
			outCP.print(chargePlan[i].getPlanType());
			outCP.println("");
		}
		
		outCP.close();
		
		/* ---------------------------------------------------------------------- */
		
		/* ---------------------------------------------------------------------- */
		
		Writer writerVas = null;
		File writeVasFile = new File("VASInfo.txt");
		PrintWriter outVas = new PrintWriter (writeVasFile);
		
		for (int i=0; i<vasCounter; i++)
		{
			if(vas[i].getCode().compareTo("")!=0)
			{
				outVas.print(vas[i].getAccNo() + "\t");
				outVas.print(vas[i].getSubAccountNo() + "\t");
				outVas.print(vas[i].getCode() + "\t");
				outVas.print(vas[i].getType());
				outVas.println("");
			}
		}
		
		outVas.close();
		
		/* ---------------------------------------------------------------------- */
		
	/* ------------------------------------------------------------------------------------------ */
		
    	System.out.println("\nBye Bye\n");
    
    }
    
    
}





Account Class


public class Account 
{

	//Instance Variables
	private String name, address, type, creationDate, status, age;
	private int accNo;
	
	private String[] accounts = new String[100];
	
	//Constructor
    public Account(int iAccNo, String iName, String iAddress, String iAge, String iType)
    {
    	this.accNo = iAccNo;
    	this.name = iName;
    	this.address = iAddress;
    	this.age = iAge;
    	this.type = iType;
    	this.status = "Active";
    	this.creationDate = VAS.getDateTime();
    }
    
    //Constructor (Construct object from Customer.txt)
     public Account(int iAccNo, String iName, String iAddress, String iAge, String iType, String iStatus, String iDate)
    {
    	this.accNo = iAccNo;
    	this.name = iName;
    	this.address = iAddress;
    	this.age = iAge;
    	this.type = iType;
    	this.status = iStatus;
    	this.creationDate = iDate;
    }
    
    //Accessor
    public int getAccNo()
 	{
 		return accNo;
 	}
    
    public String getName()
    {
    	return name;
    }
    
    public String getAddress()
    {
    	return address;
    }
    
    public String getAge()
    {
    	return age;
    }
    
    public String getType()
    {
    	return type;
    }
    
    public String getStatus()
    {
    	return status;
    }
 	
 	public String getCreationDate()
 	{
 		return creationDate;
 	}
 	
 	public void getAccountInfo()
 	{
 		System.out.printf("%-10d", accNo);
		System.out.printf("%-16s", name);
		System.out.printf("%-20s", address);
		System.out.printf("%-6s", age);
		System.out.printf("%-14s", type);
		System.out.printf("%-10s", status);
		System.out.println("");
 	}
 	
 	public void getDetails()
 	{
 		System.out.println("");
		System.out.println("----------------------------------------------\n");
		System.out.println("Account No.      : " + accNo );
		System.out.println("Customer Name    : " + name );
		System.out.println("Customer Address : " + address );
		System.out.println("Customer Age     : " + age );
		System.out.println("Customer Type    : " + type );
		System.out.println("Date Registered  : " + creationDate );
		System.out.println("");
		System.out.println("----------------------------------------------\n");
 	}
 	
 	//Mutators
 	public void setName(String iName)
 	{
 		this.name = iName;
 	}
 	
 	public void setAddress(String iAddress)
 	{
 		this.address = iAddress;
 	}
 	
 	public void setAge(String iAge)
 	{
 		this.age = iAge;
 	}
 	
 	public void setType(String iType)
 	{
 		this.type = iType;
 	}
 	
 	public void terminateAccount()
 	{
 		if (status.equals("Inactive"))
 		{
 			System.out.println("\nThis service is already been DEACTIVATED\n");
 		}
 		else
 		{
 			this.status = "Inactive";
 			System.out.println("\nThe service is DEACTIVATED\n");
 		}
 			
 	}
 	
 	public void activateAccount()
 	{
 		if (status.equals("Active"))
 		{
 			System.out.println("\nThe Service is presently ACTIVE\n");
 		}
 		else
 		{
 			this.status = "Active";
 			System.out.println("\nThe Service has been RE-ACTIVATED\n");
 		}
 		
 	}
}





Charge Plan Class


import java.io.*;
import java.util.*;

public class ChargePlan {

	//Instance Variables
	private String planID, planName, planCharge, planVRate, planDRate, planType;
	private int mobileServiceNo, AccNo;

	//Constructor
	public ChargePlan( int iPlanNo, int iAccNo, int iMsNo, String iPlanType)
	{
		this.mobileServiceNo = iMsNo;
		this.AccNo = iAccNo;
		this.planType = iPlanType;
		
		if(iPlanType.equals("VOICE"))
		{
			if(iPlanNo == 1)
			{
				this.planID = "VP01";
			}
			else if(iPlanNo == 2)
			{
				this.planID = "VP02";
			}
			else if(iPlanNo == 3)
			{
				this.planID = "VP03";
			}
			else if(iPlanNo == 4)
			{
				this.planID = "VP04";
			}
			else if(iPlanNo == 5)
			{
				this.planID = "VP05";
			}
		}
		else
		{
			if(iPlanNo == 1)
			{
				this.planID = "DP01";
			}
			else if(iPlanNo == 2)
			{
				this.planID = "DP02";
			}
			else if(iPlanNo == 3)
			{
				this.planID = "DP03";
			}
		}
	}
	
	//Constructor
	public ChargePlan(int iAccNo, int iMobileServiceNo, String planID, String iPlanType) {
		this.mobileServiceNo = iMobileServiceNo;
		this.AccNo = iAccNo;
		this.planID = planID ;
		this.planType = iPlanType;
	}
	
	public int getAccNo()
	{
		return AccNo;
	}
	
	public int getSubAccountNo()
	{
		return mobileServiceNo;
	}
	
	public String getPlanID()
	{
		return planID;
	}
	
	public String getPlanType()
	{
		return planType;
	}
	
	public void changePlanID( String iPlanID )
	{
		this.planID = iPlanID;
	}
    	
	//Plan Name
	public String getPlanName()
	{
		if ( planID.equals("VP01"))
		{
			this.planName = "Value First";
		}
		else if( planID.equals("VP02"))
		{
			this.planName = "Value Plus 50";
		}
		else if( planID.equals("VP03"))
		{
			this.planName = "Value Plus 80";
		}
	    else if( planID.equals("VP04"))
		{
			this.planName = "Value Plus 150";
		}
		else if( planID.equals("VP05"))
		{
			this.planName = "Value Plus 250";
		}    		
		else if( planID.equals("DP01"))
		{
			this.planName = "Data 1.5GB";
		}    
		else if( planID.equals("DP02"))
		{
			this.planName = "Data 3.0GB";
		}    
		else if( planID.equals("DP03"))
		{
			this.planName = "Data 6.0GB";
		}    
			    			
		return planName;
	}
    	
	public static void displayChargeVoicePlan()
	{
		System.out.println("---------------------------------------------------------------");
		System.out.println("-                   Voice Charge Plan                         -");
		System.out.println("-                                                             -");
		System.out.println("- No. Plan ID | Plan Name       | Charges/Min | Charges/Month -");
		System.out.println("---------------------------------------------------------------");
		System.out.println("- 1.  VP01    | Value First     |       0.18  |           30  -");
		System.out.println("- 2.  VP02    | Value Plus 50   |       0.12  |           50  -");
		System.out.println("- 3.  VP03    | Value Plus 80   |       0.12  |           80  -");
		System.out.println("- 4.  VP04    | Value Plus 150  |       0.10  |          150  -");
		System.out.println("- 5.  VP05    | Value Plus 250  |       0.10  |          250  -");
		System.out.println("-                                                             -");
		System.out.println("- 6.  Back                                                    -");
		System.out.println("---------------------------------------------------------------");
	}	
	
	
	public static void displayChargeDataPlan()
	{
		System.out.println("-------------------------------------------------");
		System.out.println("-        Data Charge Plan                       -");
		System.out.println("-                                               -");
		System.out.println("- No. Plan ID | Plan Name       | Charges/Month -");
		System.out.println("-------------------------------------------------");
		System.out.println("- 1.  VP01    | Data 1.5GB      |           48  -");
		System.out.println("- 2.  VP02    | Data 3.0GB      |           68  -");
		System.out.println("- 3.  VP03    | Data 6.0GB      |           98  -");
		System.out.println("-                                               -");
		System.out.println("- 4.  Back                                      -");
		System.out.println("-------------------------------------------------");
	}
		    		        	
	//Voice Plan Rate
	public String getPlanVoiceRate()
	{
		if (planID.equals("VP01"))
		{
			this.planVRate = "0.18";
		}    	
		else if(planID.equals("VP02"))
		{
			this.planVRate = "0.12";
		}
		else if(planID.equals("VP03"))
		{
			this.planVRate = "0.12";
		} 
		else if(planID.equals("VP04"))
		{
			this.planVRate = "0.10";
		} 
		else if(planID.equals("VP05"))
		{
			this.planVRate = "0.10";
		}
	    		
		return planVRate;
	}		
/*
	//Data Plan Rate
	public String getPlanDRate()
	{
		if( planID.equals("DP01"))
		{
			this.planDRate = "0.50";
		}
		else if( planID.equals("DP02"))
		{
			this.planDRate = "0.30";
		}
		else if( planID.equals("DP02"))
		{
			this.planDRate = "0.10";
		}	    		
		return planDRate;
	}
*/
}




Log Class


import java.io.*;
import java.util.Scanner;
import java.text.DateFormat;
import java.util.*;

public class Log
{	
	static Calendar calendar = new GregorianCalendar();
	static String time;
	static String dateAndTime="";
	
	static int accNo;
	static String type="", activity="", option="";

    public Log() {
    }
    
    public static void generateLog ( int accNo, String type, String act, Account[] acc )
    {
    	// e.g. : type = "info", "service", "account", "vas"
    	
    	int xaccNo = accNo + 1;
    	
    	if ( act.equals("create") )
    	{	
    		activity = "An account " + xaccNo + " '" + acc[accNo].getName() + "'" + " is created";
    	}
    	
    	else if ( act.equals("edit") )
    	{
    		activity = "Account " + xaccNo + " '" + acc[accNo].getName() + "' " + type + " is edited";
    	}
    	else if ( act.equals("terminate") )
    	{
    		activity = "Account " + xaccNo + " '" + acc[accNo].getName() + "' " + type + " is terminated";
    	}
    	else if ( act.equals("add") )
    	{
    		activity = "A new " + type + " is added to account no " + xaccNo + " - " + acc[accNo].getName();
    	}
    	else if ( act.equals("remove") )
    	{
    		activity = "A " + type + " is removed from account no " + xaccNo + " - " + acc[accNo].getName();
    	}
    	else if ( act.equals("activate") )
    	{
    		activity = "Account no " + xaccNo + "' " + acc[accNo].getName() + " '" + type +" is activated again";
    	}
    	else if ( act.equals("login") )
    	{
    		activity = type + " has logged in";
    	}
    	else if ( act.equals("logout") )
    	{
    		activity = type + " has logged out";
   		}
    	
    	/* ----------------- WRITE TO FILE ----------------- */
    	
	    	try
	    	{
	    		FileWriter fstream = new FileWriter ( "log.txt", true );
	    		BufferedWriter out = new BufferedWriter ( fstream );
	    		
	    		out.write( activity + " on " + getDateAndTime() );
	    		out.newLine();
	    		out.newLine();
	    		
	    		out.close();
	    	}
	    	
	    	catch ( Exception e )
	    	{
	    		System.err.println ( "Error: " + e.getMessage() );
	    	}
	    	
	    	
    	/* ------------------------------------------------- */
    	
    }
    
    public void generateTime()
    {
    	String hour = "" + calendar.get( Calendar.HOUR );
    	String minute = "" + calendar.get( Calendar.MINUTE );
    	String second = "" + calendar.get( Calendar.SECOND );
    	
    	time = hour + ":" + minute + ":" + second;
    }
    
    public void generateDate()
    {
    	String date = "" + calendar.get ( Calendar.DATE );
    	String month = "" + calendar.get ( Calendar.MONTH );
    	String year = "" + calendar.get ( Calendar.YEAR );
    	
    	
    }
    
    public String getTime()
    {
    	return time;
    }
    
    public static String getDateAndTime()
    {
    	dateAndTime = "" + new Date();
    	
    	return dateAndTime;
    }
    
   
    
   
    
}




Services Class


import java.io.*;
import java.util.Scanner;
import java.text.DateFormat;
import java.util.*;

public class Services {

	//Instance Variables
	private String registerationDate, terminationDate, status, imsi, serviceNo, serviceType, creationDate;
	private double currentOutstanding, lastBillAmount;
	private int accNo, subAccountNo;
	static String sysDate;
	
	//Constructor
	public Services( int iAccNo, int iSubAccountNo, String iType ) 
	{
		this.accNo = iAccNo;
		this.subAccountNo = iSubAccountNo;
		this.serviceType = iType;
		this.status = "ACTIVE";
		this.creationDate = VAS.getDateTime();
	}
	
	//Constructor (Construct object from MobileServices.txt)
	public Services ( int iAccNo, int iSubAccountNo, String iType, String iServiceNo, String iIMSI, String iStatus, String iDate )
	{
		this.accNo = iAccNo;
		this.subAccountNo = iSubAccountNo;
		this.serviceType = iType;
		this.serviceNo = iServiceNo;
		this.imsi = iIMSI;
		this.status = iStatus;
		this.creationDate = iDate;
	}
	
	//Method for getting system date
	public String sysDate()
	{
		Date sysdate = new Date();
		String date = DateFormat.getDateInstance().format(sysdate);
		sysDate = date.toString();
		return sysDate;
	}
	
	//Accessor
	public int getAccNo()
	{
		return accNo;
	}
	
	public int getSubAccountNo()
	{
		return subAccountNo;
	}
	
	public String getServiceType()
	{
		return serviceType;
	}
	
	public String getServiceNo()
	{
		return serviceNo;
	}
	
	public String getIMSI()
	{
		return imsi;
	}
	
	public String getStatus()
	{
		return status;
	}
	
	public String getCreationDate()
	{
	   return creationDate;
	}
	
	public void registerationDate()
	{
		sysDate();
		registerationDate = sysDate;
	}
	
	public void terminationDate()
	{
		sysDate();
		terminationDate = sysDate;
	}
   
	//Randomize Generate IMSI number
	public void generateIMSI()
	{
		Random IMSI = new Random(); 
		int sim[] = new int[2];
		sim[0] = (IMSI.nextInt(99999999));
		sim[1] = (IMSI.nextInt(99999999));
		
	//Combine 2 number in String
		String sim1 = "" + sim[0];
		String sim2 = "" + sim[1];
		imsi = sim1 + sim2;
	}
	
	//Randomize Generate Services Number (Format 01X-XXX XXXX)
	public void generateServiceNo()
	{
		Random serviceNumber = new Random();
		int number[]= new int[2];
		number[0] = (serviceNumber.nextInt(9));
		number[1] = (serviceNumber.nextInt(9999999));
		
		serviceNo = "01" + number[0]+"-"+number[1];
	}
	
	public void deactivateService()
	{
		if ( status.equals("INACTIVE") )
		{
			System.out.println("\nThis service is already been DEACTIVATED\n");
		}
		else
		{
			this.status = "INACTIVE";
			System.out.println("\nThe service is DEACTIVATED\n");
		}
			
	}
	
	public void activateService()
	{
		if ( status.equals("ACTIVE") )
		{
			System.out.println("\nThe Service is presently ACTIVE\n");
		}
		else
		{
			this.status = "ACTIVE";
			System.out.println("\nThe Service has been RE-ACTIVATED\n");
		}
		
	}
	
	public void terminateStatus()
	{
		status = "INACTIVE";
	}
	
	public void removeServices()throws Exception
	{
		
	}
	
	public void viewServices()
	{
		
	}
}




VAS class


import java.text.DateFormat;
import java.util.Date;
import java.text.*;

public class VAS {

	//Instance Variables
	private String name, code, dateSubscribe, charge, type;
	private double rate;
	private int accNo, subAccountNo;
	public static int voiceService1=0, voiceService2=0, voiceService3=0;
	public static int dataService1=0, dataService2=0;
	
	//Constructor
	public VAS(int iVASNo, int iAccNo, int iSubAccountNo, String iPlanType)
	{
		this.accNo = iAccNo;
		this.subAccountNo = iSubAccountNo;
		this.type = iPlanType;
		if(iPlanType.equals("VOICE"))
		{
			if(iVASNo == 1)
			{
				code = "V001";
				name = "Call Forwarding";
				voiceService1 = 1;
			}
			else if(iVASNo == 2)
			{
				code = "V002";
				name = "Call Waiting";
				voiceService2 = 1;
			}
			else if(iVASNo == 3)
			{
				code = "V003";
				name = "Caller ID Restriction (CLIR)";
				voiceService3 = 1;
			}
		}
		else if (iPlanType.equals("DATA"))
		{
			if(iVASNo == 1)
			{
				code = "D001";
				name = "Voice2Go";
				dataService1 = 1;
			}
			else if(iVASNo == 2)
			{
				code = "D002";
				name = "Internet Security";
				dataService2 = 1;
			}
		}
	}
	
	public static String checkVas( int iVASNo, String iType)
	{
		String check="";
		
		if(iType.equals("VOICE"))
		{
			if(iVASNo == 1)
			{
				check = "V001";
				return check;
			}
			else if(iVASNo == 2)
			{
				check = "V002";
				return check;
			}
			else if(iVASNo == 3)
			{
				check = "V003";
				return check;
			}
		}
		
		else if (iType.equals("DATA"))
		{
			if(iVASNo == 1)
			{
				check = "D001";
				return check;
			}
			else if(iVASNo == 2)
			{
				check = "D002";
				return check;
			}
		}
		return check;
	}

    public VAS(int iAccNo, int iSubAccountNo, String iCode, String iType) 
    {  	
    	this.accNo = iAccNo;
		this.subAccountNo = iSubAccountNo;
		this.code = iCode;
		this.type = iType;
    }
    
    //Accessor
   	public int getAccNo()
	{
		return accNo;
	}
	
	public int getSubAccountNo()
	{
		return subAccountNo;
	}	
	
	public String getCode()
	{
		return code;
	}
	
	public String getType()
	{
		return type;
	}
	
	public String getName()
	{
		return name;
	}
	
	public double getRate()
	{
		return rate;
	}
	
	public String getDate()
	{
		return dateSubscribe;
	}
	
	public String getCharge()
	{
		return charge;
	}
	
    public static void displayVoiceTypeVAS()
    {
    	System.out.println("-------------------------------------------------------------");
		System.out.println("-                Voice Value Added Services                 -");
		System.out.println("-                                                           -");
		System.out.println("- No. VAS ID |          VAS Name            | Charges/Month -");
		System.out.println("-------------------------------------------------------------");
		System.out.println("- 1.  V001   | Call Forwarding              |         3.00  -");
		System.out.println("- 2.  V002   | Call Waiting                 |         3.00  -");
		System.out.println("- 3.  V003   | Caller ID Restriction (CLIR) |         5.00  -");
		System.out.println("-                                                           -");
		System.out.println("- 4.  Back                                                  -");
		System.out.println("-------------------------------------------------------------");
    }	

    public static void displayDataTypeVAS()
    {
    	System.out.println("-------------------------------------------------------------");
		System.out.println("-                Data Value Added Services                  -");
		System.out.println("-                                                           -");
		System.out.println("- No. VAS ID |          VAS Name            | Charges/Month -");
		System.out.println("-------------------------------------------------------------");
		System.out.println("- 1.  D001   | Voice2Go                     |           **  -");
		System.out.println("- 2.  D002   | Internet Security            |         8.00  -");
		System.out.println("-                                                           -");
		System.out.println("- 3.  Back                                                  -");
		System.out.println("-------------------------------------------------------------");
		System.out.println("**RM0.15/Min.");
    }
    
    public String getVASName()
    {
    	if (code.equals("V001"))
		{
			this.name = "Call Forwarding";
		}
		else if(code.equals("V002"))
		{
			this.name = "Call Waiting";
		}
		else if(code.equals("V003"))
		{
			this.name = "Caller ID Restriction (CLIR)";
		}
	    else if(code.equals("D001"))
		{
			this.name = "Voice2Go";
		}
		else if(code.equals("D002"))
		{
			this.name = "Internet Security";
		}    		      			
		return name;
    }
    
    public static String getDateTime() 
    {
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        Date dates = new Date();
        return dateFormat.format(dates);
    }
    
    public void getVASDetails()
    {
    	System.out.println(code);
    }
    
    public void deleteVASCode()
    {
    	code = "";
    }
    
    public void changeName(String name)
    {
    	this.name = name;
    }
    
    public void changeRate(double rate)
    {
    	this.rate = rate;
    }
    
    public void changeCharge(String charge)
    {
    	this.charge = charge;
    }
}




Guys, i dont have the proper understanding of file handling, and unable to save my data withing a .dat file. I have completed all the requirements and im finding this requirement quite unstable. Please help me out :(

Is This A Good Question/Topic? 0
  • +

Replies To: Need Help in File Handling

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2876
  • View blog
  • Posts: 11,051
  • Joined: 15-July 08

Re: Need Help in File Handling

Posted 07 October 2010 - 06:27 PM

Alright, well first thing's first. Honestly, sorry to say, you actually have posted too much code for a preliminary post and it is VERY difficult to help you when you post multi-thousand line code. Narrow down what your problem is and then ask us how to fix it and provide the specific code relevant to that portion.

Also, typically, it is not a good thing to have methods that are that long. Generally, methods should be completely seen in one IDE window. IF it can't be seen, you might consider writing other methods/objects to help reduce the code in each method. This will make it easier to read and overall make it more extensible.
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8347
  • View blog
  • Posts: 31,913
  • Joined: 06-March 08

Re: Need Help in File Handling

Posted 07 October 2010 - 06:49 PM

I can't beleive you wrote so many lines of code without testing them

It started to brake when you added which part ?

It is not a good practice at all to have multiple static methods as you do in your first class you are a lot better to create a CMM object to handle the behaviour of the class

All classes should have a main() method for unit tests purpose. Then you can post the class that generates the problem.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1