8 Replies - 383 Views - Last Post: 17 July 2011 - 06:38 PM Rate Topic: -----

#1 ahbrahim2  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 21-September 09

Problem outputting data into file

Posted 17 July 2011 - 04:53 PM

I have problem displaying my out put of my program to a file. There is no build error but the program wont output the data.
package personclass;


import java.util.*;
import java.io.*;
public class Address {
    
     
      private String streetName; //variable to store stree name
      private String cityName; //variable to store the city 
      private String stateName; //variable to store the sate 
      private int zip; //variable to store the zip 
      private long  phoneNumber;
        
       
    public Address() 
            { 
                   
                    streetName = "";
                    cityName = ""; 
                    stateName = ""; 
                    zip = 46517;
                    phoneNumber = 5743220709L;
                    
            } 


    public Address( String strName, String ctyName, String stName, int Zip, long phNumber) 
    { 
            
            streetName = strName; 
            cityName = ctyName; 
            stateName = stName;
            zip = Zip;
            phoneNumber = phNumber;
    }
    
    
    public void setAddress( String strName, String ctyName, String sttName, int Zip, long phNumber)
    {
           
            streetName = strName; 
            cityName = ctyName; 
            stateName = sttName;
            zip = Zip;   
             phoneNumber = phNumber;
    }
    
   
      
     public void setStreetName(String strName)
     {
         streetName = strName;
     }
      
     public void setCityName(String ctyName)
     {
           cityName = ctyName; 
     }
     
     public void setStateName(String sttName)
     {
         stateName = sttName;
            
     }
    
     
     public void setZipCode(int Zip)
     {
         zip = Zip; 
     }
    
     
     public void setPhoneNumber(long phNumber)
     {
         phoneNumber = phNumber;
     }
     
     
      public void print()
     {
         System.out.printf("%-12s%-15s%4s", streetName, cityName,
                                            stateName, zip, phoneNumber );
         
     }
     
     public void print (PrintWriter outp)
     {
         outp.printf("%-12s%-15s%4s", streetName, cityName,
                                            stateName, zip, phoneNumber);
     }
     
     
     
     public String getStreetName()
     {
         return streetName;
     }
     
     public String getCity() 
    { 
        return cityName; 
    } 
    
    
    public String getState() 
    { 
         return stateName;
    }
    
    public int getZipCode() 
    { 
         return zip;
    }
 
    
    public long getphoneNumber() 
    { 
        return phoneNumber;
    }
    
    public void copyCourseInfo(Address otherAddress)
       {
          streetName = otherAddress.streetName;
          cityName = otherAddress.cityName;
          stateName = otherAddress.stateName;
          zip = otherAddress.zip;
          phoneNumber = otherAddress.phoneNumber;
       }

    void setPersoninfo(String fName, String lName, int month, int day, int year, String strName, 
            String ctyName, String sttName, int zip, long phNumber) {
        //setName(fName, lName);
       
       int  bMonth = month;
       int bDay = day;
       int bYear = year;
        streetName = strName;
        cityName = ctyName;
        stateName = sttName;
        zip =zip;
        phoneNumber = phNumber;
        throw new UnsupportedOperationException("Not yet implemented");
    }
    
}
   




package personclass;


import java.util.*;
import java.io.*;
public class AddressBook {
    
     static final int maxNumberOfAdresses = 500;
    
    
   
    public static void main(String[] args) throws FileNotFoundException
    {
          ExtPerson[]List = new ExtPerson[maxNumberOfAdresses];

      Scanner inFile = new Scanner (new FileReader("Ch11Ex6.txt") );
     PrintWriter outFile = new PrintWriter("Ch11Ex6.out");
     
     
            for(int i = 0; i < maxNumberOfAdresses; i++)
            {
                 List[i] = new ExtPerson();
                 
            }
     
     
     
      getPersonData(inFile, List);
      printGradeReport(outFile, List, maxNumberOfAdresses);
      inFile.close();
      outFile.close();
     
    
    }
    
    
    
      public static void getPersonData(Scanner inpFile, ExtPerson []list)
     {
         String fName;
         String lName;
         int month,  day, year;
        // long dBirth;
         String streetName; //variable to store stree name
         String cityName; //variable to store the city 
         String stateName; //variable to store the sate
         String relation;
        int zip; //variable to store the zip 
        long  phoneNumber;
         
    
         Address[] plist = new Address[10];
         
         for (int i = 0; i < 10; i++)
         {
             plist[i]=new Address();
        
             fName = inpFile.next();
             lName = inpFile.next();
             month =  inpFile.nextInt();
             day = inpFile.nextInt();
             year = inpFile.nextInt();
             //dBirth = inpFile.nextLong();
             streetName = inpFile.next();
             cityName = inpFile.next();
             stateName = inpFile.next();
             
             zip = inpFile.nextInt();
             phoneNumber = inpFile.nextLong();
            relation = inpFile.next(); 
              
             
              plist[i].setPersoninfo(fName, lName, month, day, year, streetName, cityName, stateName, zip, phoneNumber);
              
              
         }
     }
     
     
    
   public static void printGradeReport(PrintWriter outfile,
                                    ExtPerson[]pList, int maxNumberOfAdresses)
     {
         int count;
         for( count = 0; count < maxNumberOfAdresses; count++)
         pList[count].print(outfile);
     }
    
   
    
    

       
}

 


        /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package personclass;


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

public class ExtPerson extends Person
{
    private int bMonth ;
    private int bDay;
    private int bYear;
    private long BirthDay;
    private Address pAdresses;
    private Date pDate;
    private String streetName = "";
    private String  cityName = "";
    private String  stateName ="";
    private int  zip =46517;
    private long phoneNumber;
    //private char [] courseGrades;
    private Address[] pAddresses;
   int numberofPerson;
    
    public ExtPerson()
    {
        super();
        bMonth = 1;
        bDay = 1;
        bYear = 1990;
        phoneNumber = 5743220709l;
        BirthDay = 256;
        numberofPerson = 0;
        //pAdresses = new Address();
      
                
    }
    
    public void setPersoninfo(String fName, String lName, int month, 
                        int day, int year,  String strName, String ctyName, String sttName, int Zip, 
                        long phNumber, Address[] address)
    {
        setName(fName, lName);
       
        bMonth = month;
        bDay = day;
        bYear = year;
        streetName = strName;
        cityName = ctyName;
        stateName = sttName;
        zip =Zip;
        phoneNumber = phNumber;
        
         
        for ( int i = 0; i < numberofPerson; i++)
        {
            pAddresses [i].copyCourseInfo(pAddresses[i]);
        }
        //sortCourses();
        
    }
    
    
    
     public void setMonthOfBirth(int mnth)
    {
        bMonth = mnth;
    }
        
    public void setDayOfBiirthd( int day )
    {
        bDay = day;
        
    }
    
    public void setYearOfBirth(int year)
    {
        bYear = year;
        
    }
    
    

    
    public void print(PrintWriter outp)
    {
        outp.println("Student Name: " + super.toString());
        outp.println("Date of Birth : " + bMonth +" " + bDay + " " + bYear);
        outp.println("Number Of Courses enrolled " + streetName);
        outp.println("Number Of Courses enrolled " + cityName);
        outp.println("Number Of Courses enrolled " + stateName);
        outp.println("Number Of Courses enrolled " + zip);
        outp.println("Number Of Courses enrolled " + phoneNumber);
        
  
       outp.println();
      
       
    }
    
    
    
    public int getbMonth()
    {
        return  bMonth ;
        
    }
    
     public int getbDay()
    {
        return bDay;
        
    }
     
      public int getbYear()
    {
        return bYear;
        
    }
      
     
  public void setIsBirthDay( long BDay)
    {
        BirthDay = BDay;
        
    }        
    
}
        



package personclass;


public class Person {

    private String firstName;
    private String lastName;
    
    public Person()
    {
        firstName = "";
        lastName = "";
        
    }
    
    public Person(String first, String last)
    {
        setName(first, last);
        
    }
    
    public String toString()
    {
        return (firstName +" " + lastName);
        
    }
    
    public void setName(String first, String last)
    {
        firstName = first;
        lastName = last;
        
    }
    
    public String getfirstName()
    {
        return firstName;
    }
    
    public String getlastName()
    {
        return lastName;
    }
    
}



Is This A Good Question/Topic? 0
  • +

Replies To: Problem outputting data into file

#2 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1406
  • View blog
  • Posts: 3,121
  • Joined: 05-April 11

Re: Problem outputting data into file

Posted 17 July 2011 - 05:06 PM

I moved your ExtPerson and AddressBook classes into my editor and removed all of the not needed things, and it outputted to Ch11Ex6.out without any errors.

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

public class AddressBook {

	static final int maxNumberOfAdresses = 500;

	public static void main( String[] args ) throws FileNotFoundException {
		ExtPerson[] List = new ExtPerson[maxNumberOfAdresses];

		PrintWriter outFile = new PrintWriter( "Ch11Ex6.out" );

		for ( int i = 0; i < maxNumberOfAdresses; i++ ) {
			List[i] = new ExtPerson();
		}

		printGradeReport( outFile, List, maxNumberOfAdresses );
		outFile.close();

	}

	public static void printGradeReport( PrintWriter outfile, ExtPerson[] pList, int maxNumberOfAdresses ) {
		int count;
		for ( count = 0; count < maxNumberOfAdresses; count++ )
			pList[count].print( outfile );
	}
}




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

public class ExtPerson {
	private int bMonth;
	private int bDay;
	private int bYear;
	private long BirthDay;
	private Date pDate;
	private String streetName = "";
	private String cityName = "";
	private String stateName = "";
	private int zip = 46517;
	private long phoneNumber;
	//private char [] courseGrades;
	int numberofPerson;

	public ExtPerson() {
		bMonth = 1;
		bDay = 1;
		bYear = 1990;
		phoneNumber = 5743220709l;
		BirthDay = 256;
		numberofPerson = 0;
		//pAdresses = new Address();

	}

	public void setPersoninfo( String fName, String lName, int month, int day, int year, String strName, String ctyName, String sttName, int Zip, long phNumber ) {
		bMonth = month;
		bDay = day;
		bYear = year;
		streetName = strName;
		cityName = ctyName;
		stateName = sttName;
		zip = Zip;
		phoneNumber = phNumber;
	}

	public void setMonthOfBirth( int mnth ) {
		bMonth = mnth;
	}

	public void setDayOfBiirthd( int day ) {
		bDay = day;

	}

	public void setYearOfBirth( int year ) {
		bYear = year;

	}

	public void print( PrintWriter outp ) {
		outp.println( "Student Name: " + super.toString() );
		outp.println( "Date of Birth : " + bMonth + " " + bDay + " " + bYear );
		outp.println( "Number Of Courses enrolled " + streetName );
		outp.println( "Number Of Courses enrolled " + cityName );
		outp.println( "Number Of Courses enrolled " + stateName );
		outp.println( "Number Of Courses enrolled " + zip );
		outp.println( "Number Of Courses enrolled " + phoneNumber );

		outp.println();

	}

	public int getbMonth() {
		return bMonth;

	}

	public int getbDay() {
		return bDay;

	}

	public int getbYear() {
		return bYear;

	}

	public void setIsBirthDay( long BDay ) {
		BirthDay = BDay;

	}
}



I don't understand your getPersonData(Scanner inpFile, ExtPerson []list) method since it is used for nothing. You make a couple of Address objects but don't use them for anything.
Was This Post Helpful? 0
  • +
  • -

#3 ahbrahim2  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 21-September 09

Re: Problem outputting data into file

Posted 17 July 2011 - 05:28 PM

What did you removed form those classes?


View PostCasiOo, on 18 July 2011 - 01:06 AM, said:

I moved your ExtPerson and AddressBook classes into my editor and removed all of the not needed things, and it outputted to Ch11Ex6.out without any errors.

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

public class AddressBook {

	static final int maxNumberOfAdresses = 500;

	public static void main( String[] args ) throws FileNotFoundException {
		ExtPerson[] List = new ExtPerson[maxNumberOfAdresses];

		PrintWriter outFile = new PrintWriter( "Ch11Ex6.out" );

		for ( int i = 0; i < maxNumberOfAdresses; i++ ) {
			List[i] = new ExtPerson();
		}

		printGradeReport( outFile, List, maxNumberOfAdresses );
		outFile.close();

	}

	public static void printGradeReport( PrintWriter outfile, ExtPerson[] pList, int maxNumberOfAdresses ) {
		int count;
		for ( count = 0; count < maxNumberOfAdresses; count++ )
			pList[count].print( outfile );
	}
}




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

public class ExtPerson {
	private int bMonth;
	private int bDay;
	private int bYear;
	private long BirthDay;
	private Date pDate;
	private String streetName = "";
	private String cityName = "";
	private String stateName = "";
	private int zip = 46517;
	private long phoneNumber;
	//private char [] courseGrades;
	int numberofPerson;

	public ExtPerson() {
		bMonth = 1;
		bDay = 1;
		bYear = 1990;
		phoneNumber = 5743220709l;
		BirthDay = 256;
		numberofPerson = 0;
		//pAdresses = new Address();

	}

	public void setPersoninfo( String fName, String lName, int month, int day, int year, String strName, String ctyName, String sttName, int Zip, long phNumber ) {
		bMonth = month;
		bDay = day;
		bYear = year;
		streetName = strName;
		cityName = ctyName;
		stateName = sttName;
		zip = Zip;
		phoneNumber = phNumber;
	}

	public void setMonthOfBirth( int mnth ) {
		bMonth = mnth;
	}

	public void setDayOfBiirthd( int day ) {
		bDay = day;

	}

	public void setYearOfBirth( int year ) {
		bYear = year;

	}

	public void print( PrintWriter outp ) {
		outp.println( "Student Name: " + super.toString() );
		outp.println( "Date of Birth : " + bMonth + " " + bDay + " " + bYear );
		outp.println( "Number Of Courses enrolled " + streetName );
		outp.println( "Number Of Courses enrolled " + cityName );
		outp.println( "Number Of Courses enrolled " + stateName );
		outp.println( "Number Of Courses enrolled " + zip );
		outp.println( "Number Of Courses enrolled " + phoneNumber );

		outp.println();

	}

	public int getbMonth() {
		return bMonth;

	}

	public int getbDay() {
		return bDay;

	}

	public int getbYear() {
		return bYear;

	}

	public void setIsBirthDay( long BDay ) {
		BirthDay = BDay;

	}
}



I don't understand your getPersonData(Scanner inpFile, ExtPerson []list) method since it is used for nothing. You make a couple of Address objects but don't use them for anything.

Was This Post Helpful? 0
  • +
  • -

#4 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1406
  • View blog
  • Posts: 3,121
  • Joined: 05-April 11

Re: Problem outputting data into file

Posted 17 July 2011 - 05:31 PM

I removed everything that had to do with Address, just so I could test it without having to import the Address class. Also I removed the method in AddressBook that does nothing.
Was This Post Helpful? 0
  • +
  • -

#5 ahbrahim2  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 21-September 09

Re: Problem outputting data into file

Posted 17 July 2011 - 05:38 PM

View PostCasiOo, on 18 July 2011 - 01:31 AM, said:

I removed everything that had to do with Address, just so I could test it without having to import the Address class. Also I removed the method in AddressBook that does nothing.


i have removed commented out those methods but still not producing anything. here is the new one
package personclass;


import java.util.*;
import java.io.*;
public class AddressBook {
    
     static final int maxNumberOfAdresses = 500;
    
    
   
    public static void main(String[] args) throws FileNotFoundException
    {
          ExtPerson[]List = new ExtPerson[maxNumberOfAdresses];

     // Scanner inFile = new Scanner (new FileReader("Ch11Ex6.txt") );
     PrintWriter outFile = new PrintWriter("Ch11Ex6.out");
     
     
            for(int i = 0; i < maxNumberOfAdresses; i++)
            {
                 List[i] = new ExtPerson();
                 
            }
     
     
     
      //getPersonData(inFile, List);
      
      printinfo(outFile, List, maxNumberOfAdresses);
      //inFile.close();
      outFile.close();
     
    
    }
    
    
    
     /* public static void getPersonData(Scanner inpFile, ExtPerson []list)
     {
         String fName;
         String lName;
         int month,  day, year;
        // long dBirth;
         String streetName; //variable to store stree name
         String cityName; //variable to store the city 
         String stateName; //variable to store the sate
         String relation;
        int zip; //variable to store the zip 
        long  phoneNumber;
         
    
         Address[] plist = new Address[10];
         
         for (int i = 0; i < 10; i++)
         {
             plist[i]=new Address();
        
             fName = inpFile.next();
             lName = inpFile.next();
             month =  inpFile.nextInt();
             day = inpFile.nextInt();
             year = inpFile.nextInt();
             //dBirth = inpFile.nextLong();
             streetName = inpFile.next();
             cityName = inpFile.next();
             stateName = inpFile.next();
             
             zip = inpFile.nextInt();
             phoneNumber = inpFile.nextLong();
            relation = inpFile.next(); 
              
             
              plist[i].setPersoninfo(fName, lName, month, day, year, streetName, cityName, stateName, zip, phoneNumber);
              
              
         }
     }*/
     
     
    
   public static void printinfo(PrintWriter outfile,
                                    ExtPerson[]pList, int maxNumberOfAdresses)
     {
         int count;
         for( count = 0; count < maxNumberOfAdresses; count++)
         pList[count].print(outfile);
     }
    
     
}



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package personclass;


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

public class ExtPerson extends Person
{
    private int bMonth ;
    private int bDay;
    private int bYear;
    private long BirthDay;
    private Address pAdresses;
    private Date pDate;
    private String streetName = "";
    private String  cityName = "";
    private String  stateName ="";
    private int  zip =46517;
    private long phoneNumber;
    //private char [] courseGrades;
    private Address[] pAddresses;
   int numberofPerson;
    
    public ExtPerson()
    {
        super();
        bMonth = 1;
        bDay = 1;
        bYear = 1990;
        phoneNumber = 5743220709l;
        BirthDay = 256;
        numberofPerson = 0;
        //pAdresses = new Address();
      
                
    }
    
    public void setPersoninfo(String fName, String lName, int month, 
                        int day, int year,  String strName, String ctyName, String sttName, int Zip, 
                        long phNumber, Address[] address)
    {
        setName(fName, lName);
       
        bMonth = month;
        bDay = day;
        bYear = year;
        streetName = strName;
        cityName = ctyName;
        stateName = sttName;
        zip =Zip;
        phoneNumber = phNumber;
        
         
      /*  for ( int i = 0; i < numberofPerson; i++)
        {
            pAddresses [i].copyCourseInfo(pAddresses[i]);
        }*/
        //sortCourses();
        
    }
    
    
    
     public void setMonthOfBirth(int mnth)
    {
        bMonth = mnth;
    }
        
    public void setDayOfBiirthd( int day )
    {
        bDay = day;
        
    }
    
    public void setYearOfBirth(int year)
    {
        bYear = year;
        
    }
    
    

    
    public void print(PrintWriter outp)
    {
        outp.println("Student Name: " + super.toString());
        outp.println("Date of Birth : " + bMonth +" " + bDay + " " + bYear);
        outp.println("Number Of Courses enrolled " + streetName);
        outp.println("Number Of Courses enrolled " + cityName);
        outp.println("Number Of Courses enrolled " + stateName);
        outp.println("Number Of Courses enrolled " + zip);
        outp.println("Number Of Courses enrolled " + phoneNumber);
        
  
       outp.println();
      
       
    }
    
    
    
    public int getbMonth()
    {
        return  bMonth ;
        
    }
    
     public int getbDay()
    {
        return bDay;
        
    }
     
      public int getbYear()
    {
        return bYear;
        
    }
      
     
  public void setIsBirthDay( long BDay)
    {
        BirthDay = BDay;
        
    }        
    
}


Was This Post Helpful? 0
  • +
  • -

#6 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1406
  • View blog
  • Posts: 3,121
  • Joined: 05-April 11

Re: Problem outputting data into file

Posted 17 July 2011 - 05:43 PM

I copied yours and it outputted to Ch11Ex6.out for me :)
Was This Post Helpful? 0
  • +
  • -

#7 ahbrahim2  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 21-September 09

Re: Problem outputting data into file

Posted 17 July 2011 - 06:11 PM

I got the output bu not displaying all the information in the file.

I want to attach the file that i'm reading but for some reason DIC won't let me attach a file?



View Postahbrahim2, on 18 July 2011 - 01:38 AM, said:

View PostCasiOo, on 18 July 2011 - 01:31 AM, said:

I removed everything that had to do with Address, just so I could test it without having to import the Address class. Also I removed the method in AddressBook that does nothing.


i have removed commented out those methods but still not producing anything. here is the new one
package personclass;


import java.util.*;
import java.io.*;
public class AddressBook {
    
     static final int maxNumberOfAdresses = 500;
    
    
   
    public static void main(String[] args) throws FileNotFoundException
    {
          ExtPerson[]List = new ExtPerson[maxNumberOfAdresses];

     // Scanner inFile = new Scanner (new FileReader("Ch11Ex6.txt") );
     PrintWriter outFile = new PrintWriter("Ch11Ex6.out");
     
     
            for(int i = 0; i < maxNumberOfAdresses; i++)
            {
                 List[i] = new ExtPerson();
                 
            }
     
     
     
      //getPersonData(inFile, List);
      
      printinfo(outFile, List, maxNumberOfAdresses);
      //inFile.close();
      outFile.close();
     
    
    }
    
    
    
     /* public static void getPersonData(Scanner inpFile, ExtPerson []list)
     {
         String fName;
         String lName;
         int month,  day, year;
        // long dBirth;
         String streetName; //variable to store stree name
         String cityName; //variable to store the city 
         String stateName; //variable to store the sate
         String relation;
        int zip; //variable to store the zip 
        long  phoneNumber;
         
    
         Address[] plist = new Address[10];
         
         for (int i = 0; i < 10; i++)
         {
             plist[i]=new Address();
        
             fName = inpFile.next();
             lName = inpFile.next();
             month =  inpFile.nextInt();
             day = inpFile.nextInt();
             year = inpFile.nextInt();
             //dBirth = inpFile.nextLong();
             streetName = inpFile.next();
             cityName = inpFile.next();
             stateName = inpFile.next();
             
             zip = inpFile.nextInt();
             phoneNumber = inpFile.nextLong();
            relation = inpFile.next(); 
              
             
              plist[i].setPersoninfo(fName, lName, month, day, year, streetName, cityName, stateName, zip, phoneNumber);
              
              
         }
     }*/
     
     
    
   public static void printinfo(PrintWriter outfile,
                                    ExtPerson[]pList, int maxNumberOfAdresses)
     {
         int count;
         for( count = 0; count < maxNumberOfAdresses; count++)
         pList[count].print(outfile);
     }
    
     
}



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package personclass;


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

public class ExtPerson extends Person
{
    private int bMonth ;
    private int bDay;
    private int bYear;
    private long BirthDay;
    private Address pAdresses;
    private Date pDate;
    private String streetName = "";
    private String  cityName = "";
    private String  stateName ="";
    private int  zip =46517;
    private long phoneNumber;
    //private char [] courseGrades;
    private Address[] pAddresses;
   int numberofPerson;
    
    public ExtPerson()
    {
        super();
        bMonth = 1;
        bDay = 1;
        bYear = 1990;
        phoneNumber = 5743220709l;
        BirthDay = 256;
        numberofPerson = 0;
        //pAdresses = new Address();
      
                
    }
    
    public void setPersoninfo(String fName, String lName, int month, 
                        int day, int year,  String strName, String ctyName, String sttName, int Zip, 
                        long phNumber, Address[] address)
    {
        setName(fName, lName);
       
        bMonth = month;
        bDay = day;
        bYear = year;
        streetName = strName;
        cityName = ctyName;
        stateName = sttName;
        zip =Zip;
        phoneNumber = phNumber;
        
         
      /*  for ( int i = 0; i < numberofPerson; i++)
        {
            pAddresses [i].copyCourseInfo(pAddresses[i]);
        }*/
        //sortCourses();
        
    }
    
    
    
     public void setMonthOfBirth(int mnth)
    {
        bMonth = mnth;
    }
        
    public void setDayOfBiirthd( int day )
    {
        bDay = day;
        
    }
    
    public void setYearOfBirth(int year)
    {
        bYear = year;
        
    }
    
    

    
    public void print(PrintWriter outp)
    {
        outp.println("Student Name: " + super.toString());
        outp.println("Date of Birth : " + bMonth +" " + bDay + " " + bYear);
        outp.println("Number Of Courses enrolled " + streetName);
        outp.println("Number Of Courses enrolled " + cityName);
        outp.println("Number Of Courses enrolled " + stateName);
        outp.println("Number Of Courses enrolled " + zip);
        outp.println("Number Of Courses enrolled " + phoneNumber);
        
  
       outp.println();
      
       
    }
    
    
    
    public int getbMonth()
    {
        return  bMonth ;
        
    }
    
     public int getbDay()
    {
        return bDay;
        
    }
     
      public int getbYear()
    {
        return bYear;
        
    }
      
     
  public void setIsBirthDay( long BDay)
    {
        BirthDay = BDay;
        
    }        
    
}


This post has been edited by ahbrahim2: 17 July 2011 - 06:14 PM

Was This Post Helpful? 0
  • +
  • -

#8 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1406
  • View blog
  • Posts: 3,121
  • Joined: 05-April 11

Re: Problem outputting data into file

Posted 17 July 2011 - 06:31 PM

What exactly is it you want it to show that it isn't?
If it is the information about the person, then you might want to call setPersoninfo in the ExtPerson class somewhere in your program.

I believe this was what you wanted to do in your getPersonData method?
Right now this is what happens in that method:
- Creation of Address array
- Reading in data about the person
- Putting the read data into the Address objects using the setPersoninfo method
- The method ends and the Address array and objects are deleted by the garbage collector.

Don't you want to save the information you are reading into the ExtPerson array instead of the Address array? At least some of it.

This post has been edited by CasiOo: 17 July 2011 - 06:32 PM

Was This Post Helpful? 0
  • +
  • -

#9 ahbrahim2  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 21-September 09

Re: Problem outputting data into file

Posted 17 July 2011 - 06:38 PM

View PostCasiOo, on 18 July 2011 - 02:31 AM, said:

What exactly is it you want it to show that it isn't?
If it is the information about the person, then you might want to call setPersoninfo in the ExtPerson class somewhere in your program.

I believe this was what you wanted to do in your getPersonData method?
Right now this is what happens in that method:
- Creation of Address array
- Reading in data about the person
- Putting the read data into the Address objects using the setPersoninfo method
- The method ends and the Address array and objects are deleted by the garbage collector.

Don't you want to save the information you are reading into the ExtPerson array instead of the Address array? At least some of it.




Well I want to do is reading first name, last name, date birth, address and phone number for external(ch6ex11.txt) then output that file as ch11ex6.out
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1