CSC407/ECE450 Assignment 1b Sample Solution

plan.dom
Class Priority

java.lang.Object
  |
  +--plan.dom.Priority
All Implemented Interfaces:
java.lang.Comparable

public class Priority
extends java.lang.Object
implements java.lang.Comparable

Implements a priority type of {high, med, low}


Field Summary
static Priority high
           
private  int i
           
static Priority low
           
static Priority med
           
private static Priority[] prioObj
           
private static java.lang.String[] prioStr
           
 
Constructor Summary
private Priority(int i)
          Private access so that only the instances defined above can exist.
 
Method Summary
 int compareTo(java.lang.Object o)
          high > med > low
 boolean equals(java.lang.Object o)
          tests for equality of this priority with the other
static Priority get(java.lang.String name)
          Return the priority object corresponding to the given name.
 java.lang.String toString()
          converts to a standard string representation of priorities
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

prioObj

private static Priority[] prioObj

prioStr

private static java.lang.String[] prioStr

high

public static final Priority high

med

public static final Priority med

low

public static final Priority low

i

private int i
Constructor Detail

Priority

private Priority(int i)
Private access so that only the instances defined above can exist.
Method Detail

compareTo

public int compareTo(java.lang.Object o)
high > med > low
Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(java.lang.Object o)
tests for equality of this priority with the other
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
converts to a standard string representation of priorities
Overrides:
toString in class java.lang.Object

get

public static Priority get(java.lang.String name)
Return the priority object corresponding to the given name.
Parameters:
name - the name of the priority level
Returns:
the requested object or null if the name does not match

CSC407/ECE450 Assignment 1b Sample Solution