2 Replies - 2081 Views - Last Post: 19 April 2014 - 10:58 PM Rate Topic: -----

#1 javaman1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 30-March 14

Hair Salon Missing Symbol Error

Posted 19 April 2014 - 09:45 PM

When I put this code in
throw new IllegalStateOperation("SortType is invalid");
it states that it can't find the symbol IllegalStateOperation. What should I do to initialize the symbol/variable IllegalStateOperation?

Here is the entire code: :
class HairSalon implements Comparable<HairSalon> {

     static final int sortByService = 0, sortByPrice = 1, sortByTime = 2;  
  
     private String service;
     private double price;
     private int time;

     static int sortType;

     HairSalon(String s, double p, int t){
         service=s;
         price= p;
         time=t;
     }
  
     public int compareTo(HairSalon other) {
        switch(sortType) {
             case sortByService:
                return service.compareTo(other.service);
             case sortByPrice:
                return Double.compare(price, other.price);  
             case sortByTime:
                return time - other.time;
         }
         throw new IllegalStateOperation("SortType is invalid");
     }
     public static void srtService() {
   sortType = sortByService;
}
public static void srtTime() {
   sortType = sortByTime;
}

    }//================================


import java.util.Scanner; 
    class SortSalon{
        public static void main(String[] args)
     {
         HairSalon [] H = new HairSalon [6];
  
  
      H[0]= new HairSalon("Cut", 8.0, 15);
      H[1]= new HairSalon("Shampoo", 4.0, 10);
      H[2]= new HairSalon("Highlights", 15.0, 35);
      H[3]= new HairSalon("Manicure", 10.0, 20);
      H[4]= new HairSalon("Pedicure", 11.0, 30);
      H[5]= new HairSalon("Dye", 20.0, 45);
      int num;
     Scanner input = new Scanner( System.in );
     System.out.print("How do you want to sort:\n1. Name\n2. Price\n3. Time\n4. To Quit\n");
     num = input.nextInt();
     if(num == 2)
     {
        sortPrice(H);
  
     for(int i = 0; i < H.length ; i++)
     {System.out.println(H[i].getService() + "\t\t" + H[i].getPrice() + "\t" + H[i].getTime() + "\n");}
     displayTable(H);
     }
  
} // main

 public static void displayTable(HairSalon[] H)
  {
     int i;

      for(i=0; i< 2; i++)
         System.out.println("price ="+ H[i].getPrice());
  }
  public static void sortPrice(HairSalon[] H)
  {
        double a;
        HairSalon temp;
        HairSalon[] re = new HairSalon[6];
        for(int i = 0; i<H.length; i++)
        {
            for(int j = i+1; i<H.length -1;i++)
            {
                if(H[i].getPrice()-H[j].getPrice()<0)
                {
                    System.out.println("Yes");
                }
            }
        }
        
    }
  public static void sortTime(HairSalon[] H)
  {
  }
  public static void sortName(HairSalon [] H)
  {
  
  }
  
 } // SortSalon



Is This A Good Question/Topic? 0
  • +

Replies To: Hair Salon Missing Symbol Error

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10804
  • View blog
  • Posts: 40,277
  • Joined: 27-December 08

Re: Hair Salon Missing Symbol Error

Posted 19 April 2014 - 09:55 PM

The Site Questions forum isn't the place for help questions.

Moved to Java.
Was This Post Helpful? 0
  • +
  • -

#3 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Hair Salon Missing Symbol Error

Posted 19 April 2014 - 10:58 PM

What you're after is the IllegalStateException class.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1