java - I have the methods, but need program code for Grade enum -


i need write java enumeration lettergrade represents letter grades through f, including plus , minus grades. enumeration code:

public enum grade { a(true), a_plus(true), a_minus(true), b(true), b_plus(true), b_minus(true), c(true), d(true), e(true), f(false);  final private boolean passed;  private grade(boolean passed) {     this.passed = passed; }  public boolean ispassing() {     return this.passed; }   @override public string tostring() {     final string name = name();     if (name.contains("plus")) {         return name.charat(0) + "+";      }     else if (name.contains("minus")) {         return name.charat(0) + "-";      }     else {         return name;     } } 

what confused writing main program. think quite straightforward have no clue on how start it. don't want whole code. few lines give me head start. rest try figure out on own.

i imagine have student class looks this:

class student {      protected grade grade = null;        public student(grade g) {         this.grade = g;       } } 

then add method in class calling ispassing method enum:

public boolean ispassing() {     if (this.grade != null)          return this.grade.ispassing();     return false; } 

this supposing passed boolean in grade correctly set , invariant.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -