Jump to content

modmouse

Members
  • Content Count

    4
  • Joined

  • Last visited

  • Days Won

    1

About modmouse

  • Rank
    Newbie

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I'm after validation for these bellow with an explanation to what I'm trying to attempt for each one. public void setPrice(int aPrice)throws DishException { if (aPrice < 0) throw new DishException ("Price cannot not be a negative number"); price = aPrice; } Only accept numbers, and cannot be empty. public void setType(char aType) throws DishException { if(aType == 0) throw new DishException ("A dish type must be entered"); type = aType; } Only accept one letter from the following [s,m,d or S,M,D] public void setNa
  2. Main.java public static void saveAsHandler() throws IOException, DishException { String fileName = StringIO.ask("file name: "); myMenu.saveAs(fileName); } public static void openHandler() throws IOException, DishException, ClassNotFoundException { String fileName = StringIO.ask("file name: "); myMenu.open(fileName); } ========================== Menu.java public void saveAs (String aFilename) throws IOException { FileOutputStream outFile = new FileOutputStream (aFilename); ObjectOutputStream itemsFile = new ObjectOutputStream (outFile); itemsFile.wr
  3. Thanks, I also want validation to check not at the end of entering a set of data but after each piece of data has been added how best would I be able to do this?
  4. public void setType(char aType) throws DishException { if(aType.length() == 0) throw new DishException ("A dish type must be entered"); type = aType; } ERROR: object type required, but char found.[/CODE] I am using jbuilder 3 and I am aware I am using the wrong validation but since I'm unsure what is the correct method to use for char type validation I'm here to see what help I can get. Since I've not covered char before this is new too me. This is the only validation error I am having others are intiger and string without any errors. I have to keep it as character and
×
×
  • Create New...