Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

errors for testing for a class

Posted on 2005-03-03
3
Medium Priority
?
221 Views
Last Modified: 2010-04-17
Good Afternoon,
pls i need help in compiling this program when i tried to compileing the REGISTER INTERFACE CLASS  it keeps giving me a kick in the teeth i have listed all the program that i have done including the errors. can someone pls help with my errors.
thanks for your help.
       
    H:
    symbol  : constructor RegisterInterface  (int)
    location: class RegisterInterface
                r1 = new RegisterInterface(numOfStudents);
                         ^
    H:java:120: cannot resolve symbol
    symbol  : method option1  (RegisterInterface)
    location: class RegisterInterface
                                 case '1':option1(r1); break;
                                                  ^
    H:java:121: cannot resolve symbol
    symbol  : method option2  (RegisterInterface)
    location: class RegisterInterface
                                    case '2':option2(r1); break;
                                                       ^
    H:java:122: cannot resolve symbol
    symbol  : method option3  (RegisterInterface)
    location: class RegisterInterface
                           case '3':option3(r1); break;
                                        ^
    H:java:123: cannot resolve symbol
    symbol  : method option4  (RegisterInterface)
    location: class RegisterInterface
                                    case '4':option4(r1); break;
                                                       ^
    H:java:124: cannot resolve symbol
    symbol  : method option5  (RegisterInterface)
    location: class RegisterInterface
                                    case '5':option5(r1); break;
                                                       ^
    H:java:125: cannot resolve symbol
    symbol  : method option6  (RegisterInterface)
    location: class RegisterInterface
                                    case '6':option6(r1); break;
                                                       ^
    H:java:126: cannot resolve symbol
    symbol  : method option7  (RegisterInterface)
    location: class RegisterInterface
                                    case '7':option7(r1); break;
                                                       ^
    8 errors
   
     ----jGRASP wedge2: exit code for process is 1.
     ----jGRASP: operation complete.

import EasyIn;

public class RegisterInterface
{
   public static void main (String[]args)
      {
         //declare variables
            char  choice;
            int numOfStudents;
            RegisterInterface r1;
            
            //get size of list
            System.out.print("How many students on the register");
            numOfStudents = EasyIn.getInt();
            
            // create list
            r1 = new RegisterInterface(numOfStudents);
            
            // menu
            
            do
            {
            //display options
                    System.out.println("\n**********    Welcome    **********");
              System.out.println("                                   ");
              System.out.println("                                   ");
              System.out.println("[1]  Add a new student              ");
              System.out.println("[2]  Remove an student              ");
              System.out.println("[3]  Enquire fees due of a student  ");
              System.out.println("[4]  Pay fees by a student with a given amount");
              System.out.println("[5]  Enqiure the total fees due");
              System.out.println("[6]  Display all student details");
              System.out.println("[7]  Sort students according to fees due");
              System.out.println("[0]  Exit the program ");
              System.out.println("\n Enter a choice [1,2,3,4,5,6,7]: ");
              choice = EasyIn.getChar();//get choice
                         
                          switch(choice)
                          {
                             case '1':option1(r1); break;
                                case '2':option2(r1); break;
                       case '3':option3(r1); break;
                                case '4':option4(r1); break;
                                case '5':option5(r1); break;
                                case '6':option6(r1); break;
                                case '7':option7(r1); break;
                                case '0':System.out.print("\n\nExit");break;
                                default: System.out.print("\n 1-7 only");
                          }
                         
            }   while (choice != '0');
   }
}



public class Register
{
   private Student[] students;
   private int numOfStudents;
     private int maxSize;

//Constructor
   public Register(int maxSize)
   {
      students = new Student[maxSize];
      numOfStudents = 0;
   }

 
   
     public void addNewStudent(Student counter)
   {
     
      if(numOfStudents < students.length)
      {
         students[numOfStudents] = counter;
         numOfStudents ++;
          }
     
   }
     
   
     
     public int findStudent(int idNumber)
     {
        int position = -1;
          int index = 0;
          boolean hasFound = false;
         
          while(index< numOfStudents && !hasFound)
          {
             if(students[index].getID()==idNumber)
                 {
                   // a match has found
                     hasFound = true;
                     position = index;
                 }
                 index++;
          }
         
          return position;
     }
     
                 
     
   public void removeStudent(int idNumber)
     {
        int position = findStudent(idNumber);
          {
             if(position!=-1)
               {
                  for(int i = position;i<numOfStudents -1; i++)
                    {
                      students[i] = students [i+1];
                    }
                   
                    // the student is removed so update
               students[numOfStudents] = null;
               numOfStudents = numOfStudents -1;
             }
           }
      }            
                     
       public void descendingFees()
       {
         Student temp;
           
                for (int i =0;i< numOfStudents -1;i++)
                    {
                       for(int j=0;j< numOfStudents;j++)
                         {
                    // check if swap has to take place                    
                            if(students[j].getFeesDue()<students[j+1].getFeesDue())
                              {
                                 // yes so swap position of element being checked
                                 temp = students[j];
                                 students[j]=students[j+1];
                                 students[j+1] = temp;
                            }
                 }          
                }
       }              
         
       public void displayStudentDetails()
       {
          for(int i =0;i<numOfStudents;i++)
            {
               if(students[i] !=null)
                 {
                    students[i].toString();
                 }
            }
     }        
       
       
       public double getFeesDue(int id)
       {
          //locate the student with id
            int position = findStudent(id);
           
            for(int i = 0; i < numOfStudents;i++)
            {
               //an student is returned if position is valid
               //if not return null
               if(position !=-1)
                 
                      return students[position].getFeesPaid();
            }
           
            return -1;
       }
       
                               
      public void payFees(int id, int amount)
        {
         
             int position = findStudent(id);
           
             if((position!=-1)&&(students[position]!=null))
             {
                students[position].payFees(amount);
               }
          }            

          public double getTotalAmountOfFeesDue()
          {
             double total = 0;
               
               for(int i = 0; i < numOfStudents;i++)
               {
                  if(students[i]!= null)
                       total = +  students[i].getFeesDue();
               }
               return total+numOfStudents;
          }              
                   
           
     public void checkOption()
     {
         int option = 0;
           
         if(option < 1 && option > 7)
         {
            System.out.println("Invalid option pls re-enter");
         }
     }  
                 
}

abstract class Student
{  
    //Attributes
    private String name;
    private int idNumber;
    private double amountOfFeesPaid;
     
     
     
          //constructor method
      public Student(String nameIn, int idNumberIn)
      {
            name = nameIn;
                idNumber = idNumberIn;
                amountOfFeesPaid = 0;
      }
     
        public int getID()
        {
           return idNumber;
        }      
           
      public void payFees(double amountIn)
      {
            amountOfFeesPaid = amountOfFeesPaid + amountIn;
      }
     
     
      abstract public double getFeesDue();// an abstract method
     
     
          public String getName()
      {
           return name;
      }
     
         
          public String toString()
      {
             return    "Student name:"
                         + getName()
                               +"Student ID Number:"
                               + getID()
                               +"Amount of fees paid:"
                               + getFeesDue()
                               +"\n";
      }
     
        public double getFeesPaid()
      {
           return amountOfFeesPaid;
      }
         
                   
          public void setFeesPaid(double feesPaid)
          {
         amountOfFeesPaid = feesPaid; // + getFeesDue()  

          }  
}

                 
     

//class declaration
class FullTimeStudent extends Student
{
   
      //Attributes
      private double courseFee = 3000;
     
     
      //parameterised constructor
      public FullTimeStudent(double courseFeeIn)
      {
          super((String)null,(int)0);
          courseFee = courseFeeIn;
      }
     
               
        public double getFeesDue()
      {
        return courseFee-getFeesPaid();
      }
         
          public void PayFees(double amount)
          {
            setFeePaid(getFeesPaid()+amount);
            if(getFeesDue()== 0);
            //setStatus(true)
      }

}      
class PartTimeStudent extends Student
{
   
      //Attributes
      private double numberOfModules;
      private double feePerModule = 300;
         
         
     
      public PartTimeStudent( double numberOfModulesIn,double feePerModuleIn)
          {
         super((String) null, (int)0);
         numberOfModules = numberOfModulesIn;
         feePerModule = feePerModuleIn;
      }

     
       
        public void payFees(double amount)
        {
             setFeePaid(getFeesPaid()+amount);
             if(getFeesDue()== 0);
             //setStatus(true)
      }
 
                                                                     
      public double getFeesDue()
      {
          return  (numberOfModules * feePerModule)-getFeesPaid();
     
     
      }
}      
0
Comment
Question by:pete1981
1 Comment
 
LVL 25

Accepted Solution

by:
InteractiveMind earned 1000 total points
ID: 13451833
You haven't declared the methods:

  option1()
  option2()
  etc..

You also have not declared the constructor RegisterInterface(int)

>> IM
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes it necessary to set special permissions on user objects.  For instance when using a Blackberry server, the SendAs permission needs to be set. I see many admins struggle with the setting that permission only to see it disappear within a few…
I’m willing to make a bet that your organization stores sensitive data in your Windows File Servers; files and folders that you really don’t want making it into the wrong hands.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question