Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006
    Posts
    26

    Unanswered: What is wrong with these my classes?

    Hi,
    I used to program in Vb 6 before I decided to migrate to Java a year ago.

    I wrote a Student Information program in Vb 6. I now wanted to write the same program in Java.
    I designed two classes: Person and COCINClasses.The Person class ran perfectly.
    Below is the COCINStudent class that says it cannot see my constructor COCINStudent:
    import java.util.*;
    import java.util.Scanner;
    import java.util.Date;

    public class COCINStudent extends Person
    {
    /**additional attributes of a student
    *in addition to those inherited from
    *class Person.
    */
    private String admissionNo;
    private String nameOfGuardian;
    private Date admissionDate;
    private String previousSchoolAttended;
    private String set;
    private String studentType;
    private Date dateOfLeaving;
    private String classPassed;
    private String notes;
    private String photo;

    /*Default Constructor*/
    public COCINStudent()
    {
    super();
    admissionNo = "Not yet";
    nameOfGuardian = "";
    admissionDate = null;
    previousSchoolAttended = "";
    set = "Not yet";
    studentType = "";
    dateOfLeaving = null;
    classPassed = "";
    notes = "";
    photo = "";
    }

    /* another constructor. You must first of all list all the
    *instance variable in the constructor heading
    */
    public COCINStudent(String nameIn, String genderIn, String eMailIn,
    String lGCIn, String stateIn, String phoneNumberIn,
    String religionIn, String contactAddress1In,
    String contactAddress2In,String admissionNoIn, String nameOfGuardianIn,
    Date admissionDateIn, String previousSchoolAttendedIn,
    String setIn, String studentTypeIn,Date dateOfLeavingIn,
    String classPassedIn, String notesIn, String photoIn,
    int year, int month, int day)
    {
    super(nameIn, genderIn, eMailIn, lGCIn, stateIn,
    phoneNumberIn, religionIn, contactAddress1In,
    contactAddress2In, year, month, day);

    admissionNo = admissionNoIn;
    nameOfGuardian = nameOfGuardianIn;
    //admissionDate = admissionDateIn;
    previousSchoolAttended = previousSchoolAttendedIn;
    set = setIn;
    studentType = studentTypeIn;
    classPassed = classPassedIn;
    notes = notesIn;
    photo = photoIn;
    GregorianCalendar calendar
    = new GregorianCalendar(year, month - 1, day);
    admissionDate = calendar.getTime();
    dateOfLeaving = calendar.getTime();
    }

    /*We have to set the attributes*/
    public void setAdmissionNo(String admissionNoIn)
    {
    admissionNo = admissionNoIn;
    }
    public void setNameOfGuardian(String nameOfGuardianIn)
    {
    nameOfGuardian = nameOfGuardianIn;
    }
    public void setAdmissionDate(Date admissionDateIn)
    {
    admissionDate = admissionDateIn;
    }
    public void setPreviousSchoolAttended(String previousSchoolAttendedIn)
    {
    previousSchoolAttended = previousSchoolAttendedIn;
    }
    public void set(String setIn)
    {
    set = setIn;
    }
    public void setStudentType(String studentTypeIn)
    {
    studentType = studentTypeIn;
    }

    public void setDateOfLeaving(Date dateOfLeavingIn)
    {
    dateOfLeaving = dateOfLeavingIn;
    }
    public void setClassPassed(String classPassedIn)
    {
    classPassed = classPassedIn;
    }
    public void setNotes(String notesIn)
    {
    notes = notesIn;
    }
    public void setPhoto(String photoIn)
    {
    photo = photoIn;
    }

    //Accessor methods
    public String getAdmissionNo()
    {
    return admissionNo;
    }
    public String getNameOfGuardian()
    {
    return nameOfGuardian;
    }
    public Date getAdmissionDate()
    {
    return admissionDate;
    }
    public String getPreviousSchoolAttended()
    {
    return previousSchoolAttended;
    }
    public String getSet()
    {
    return set;
    }
    public String getStudentType()
    {
    return studentType;
    }
    public Date getDateOfLeaving()
    {
    return dateOfLeaving;
    }
    public String getClassPassed()
    {
    return classPassed;
    }
    public String getNotes()
    {
    return notes;
    }
    public String getPhoto()
    {
    return photo;
    }

    //Define the equals method for COCINStudent class
    public boolean equals(Object otherObject)
    {

    /* super.equals checked that this and otherObject
    *belong to the same class*/
    if(!super.equals(otherObject) ) return false;
    COCINStudent other = (COCINStudent) otherObject;

    //Now test whether the fields have identical values
    return admissionNo.equals(other.admissionNo)
    && nameOfGuardian == other.nameOfGuardian
    && admissionDate.equals( other.admissionDate)
    && previousSchoolAttended == other.previousSchoolAttended
    && set == other.set
    && studentType == other.studentType
    && dateOfLeaving.equals(other.dateOfLeaving)
    && classPassed == other.classPassed
    && notes == other.notes
    && photo == other.photo;
    }

    public String toString()
    {
    return super.toString()

    + "[admission No = " + admissionNo
    + "\nName of Guardian = " + nameOfGuardian
    + "\nAdmission Date = " + admissionDate
    + "\nPrevious School Attended = " + previousSchoolAttended
    + "\nSet = " + set
    + "\nStudent Type = " + studentType
    + "\nDate of Leaving = " + dateOfLeaving
    + "\nClass Passed = " + classPassed
    +"\nNotes = " + notes
    +"\nPhoto = " + photo
    + "]";
    }

    public static void main(String[] args)
    {

    COCINStudent coStudent = new COCINStudent("Dan Abutu",
    "Male","abutu@yahoo.com","Ogori-Magongo","Kogi",
    "08059465371","Muslim","St Peter's Compound","Box 305, Ogori",
    1948,8,19,"GTC 01","Pelemo Joel",1962, 1,17,
    "GSS Okene","1968","Form", 1970,11, 28,"Year Five",
    "He was Head Student","None");

    System.out.println("List of Students:-");
    System.out.println(coStudent);
    }
    }





    My problem is with the COCINStudent class. Without the main method, it compiled fine. When I added the main class, compiled and ran the program, it complained that it cannot see the class COCINStudent! Honestly I have tried to fish out why the compiler is saying so.
    Please, let a good samaritan help me out. Without the solution I can't move ahead with Java.
    Thank you for your help. I wait eagerly for your reply.
    Akinyemi

  2. #2
    Join Date
    Sep 2010
    Posts
    7
    Sorry about my english,

    Could you paste the error here, please ?

    If the error is something like "ClassNotFound" may be the main method call is not being done properly, i.e., some error in classpath.

    []s

    Diego

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •