-1

Who could help me with exceptions, I have a task to make a small simulation of student app for university. So I have a log in page and in that page I have labels and text fields for name, surname, adress, city and student index book. I have to make a several classes for exception and main class will be studentexceptions and other will be subclasses in which I will have nameException, surnameException, adressException, cityException and indexBookException. What should I put in studentException? Maybe to make it abstract?

public class cityIsNotValidException extends StudentException {
    private String city;

    public cityIsNotValidException(String city){
        super("Name of the city is not valid "+city);
        this.city=city;
    }

    public String getCity(){
        return city;
    }
}
m_callens
  • 6,100
  • 8
  • 32
  • 54
Mapet
  • 109
  • 1
  • 8
  • 1
    Please read, how to create a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) – GAlexMES Mar 13 '17 at 09:42
  • 1
    Java convention is to make class names pascal-case, LikeThis (capital first letter). – Jiri Tousek Mar 13 '17 at 09:51
  • Yes, i know but iwas in a hurry to adit post cause i was translating name of the class to english,sorry .but thanks, i will check your solution – Mapet Mar 13 '17 at 09:53

1 Answers1

0

If the point of StudentException is merely to differentiate between application-specific exceptions and general exceptions, then it may be empty apart of needed constructors.

If you do not want anyone to throw StudentExcpetion (only want to allow subclasses to be thrown), then make it abstract.

Jiri Tousek
  • 12,211
  • 5
  • 29
  • 43