In: Computer Science
Enumerations
Interfaces
1.
//enuMonths.java : Java enumeration enuMonths to represent months
public enum enuMonths {
JANUARY("January","Jan",1,31,false),
FEBRUARY("February","Feb",2,28,true),
MARCH("March","Mar",3,31,false),
APRIL("April","Apr",4,30,false),
MAY("May","May",5,31,false),
JUNE("June","Jun",6,30,false),
JULY("July","Jul",7,31,false),
AUGUST("August","Aug",8,31,false),
SEPTEMBER("September","Sep",9,30,false),
OCTOBER("October","Oct",10,31,false),
NOVEMBER("November","Nov",11,30,false),
DECEMBER("December","Dec",12,31,false);
public String friendlyName;
public String shortName;
public int monthNumber;
public int daysInMonth;
public boolean isLeapYearMonth;
private EnuMonths(String friendlyName, String shortName, int monthNumber, int daysInMonth, boolean isLeapYearMonth)
{
this.friendlyName = friendlyName;
this.shortName = shortName;
this.monthNumber = monthNumber;
this.daysInMonth = daysInMonth;
this.isLeapYearMonth = isLeapYearMonth;
}
}
//end of enuMonths.java
2.
//enuCards.java : Java enumeration enuCards to represent blackjack cards
public enum enuCards {
A_H("Ace of Hearts",1,11),
TWO_H("2 of Hearts",2,2),
THREE_H("3 of Hearts",3,3),
FOUR_H("4 of Hearts",4,4),
FIVE_H("5 of Hearts",5,5),
SIX_H("6 of Hearts",6,6),
SEVEN_H("7 of Hearts",7,7),
EIGHT_H("8 of Hearts",8,8),
NINE_H("9 of Hearts",9,9),
TEN_H("10 of Hearts",10,10),
J_H("Jack of Hearts",10,10),
Q_H("Queen of Hearts",10,10),
K_H("King of Hearts",10,10),
A_D("Ace of Diamonds",1,11),
TWO_D("2 of Diamonds",2,2),
THREE_D("3 of Diamonds",3,3),
FOUR_D("4 of Diamonds",4,4),
FIVE_D("5 of Diamonds",5,5),
SIX_D("6 of Diamonds",6,6),
SEVEN_D("7 of Diamonds",7,7),
EIGHT_D("8 of Diamonds",8,8),
NINE_D("9 of Diamonds",9,9),
TEN_D("10 of Diamonds",10,10),
J_D("Jack of Diamonds",10,10),
Q_D("Queen of Diamonds",10,10),
K_D("King of Diamonds",10,10),
A_S("Ace of Spades",1,11),
TWO_S("2 of Spades",2,2),
THREE_S("3 of Spades",3,3),
FOUR_S("4 of Spades",4,4),
FIVE_S("5 of Spades",5,5),
SIX_S("6 of Spades",6,6),
SEVEN_S("7 of Spades",7,7),
EIGHT_S("8 of Spades",8,8),
NINE_S("9 of Spades",9,9),
TEN_S("10 of Spades",10,10),
J_S("Jack of Spades",10,10),
Q_S("Queen of Spades",10,10),
K_S("King of Spades",10,10),
A_C("Ace of Clubs",1,11),
TWO_C("2 of Clubs",2,2),
THREE_C("2 of Clubs",3,3),
FOUR_C("4 of Clubs",4,4),
FIVE_C("5 of Clubs",5,5),
SIX_C("6 of Clubs",6,6),
SEVEN_C("7 of Clubs",7,7),
EIGHT_C("8 of Clubs",8,8),
NINE_C("9 of Clubs",9,9),
TEN_C("10 of Clubs",10,10),
J_C("Jack of Clubs",10,10),
Q_C("Queen of Clubs",10,10),
K_C("King of Clubs",10,10);
public String friendlyName;
public int minPointValue;
public int maxPointValue;
private EnuCards(String friendlyName, int minPointValue, int maxPointValue)
{
this.friendlyName = friendlyName;
this.minPointValue = minPointValue;
this.maxPointValue = maxPointValue;
}
}
//end of enuCards.java
3.
//enuDays.java : Java enumeration enuDays to represent days
public enum enuDays {
SUNDAY("Sunday","Sun",1),
MONDAY("Monday","Mon",2),
TUESDAY("Tuesday","Tue",3),
WEDNESDAY("Wednesday","Wed",4),
THURSDAY("Thursday","Thu",5),
FRIDAY("Friday","Fri",6),
SATURDAY("Saturday","Sat",7);
public String friendlyName;
public String shortName;
public int dayNumber;
private EnuDays(String friendlyName, String shortName, int dayNumber)
{
this.friendlyName = friendlyName;
this.shortName = shortName;
this.dayNumber = dayNumber;
}
}
//end of enuDays.java
4.
//iVendingMachine.java : Vending Machine Interface
public interface iVendingMachine {
// method to select the index of the item
public void selectItem(int i);
// method to insert the money to buy the selected item
public void insertMoney(int i, double money);
// method to return the change corresponding to the money inserted and item selected
public double returnBalance(int i, double moneyInserted);
}
//end of iVendingMachine.java
//iAutomobile.java : iAutomobile interface
public interface iAutomobile {
// method to start the automobile
public void start();
// method to accelerate the automobile's speed
public void acceleterate();
// method to apply brakes
public void brake();
// method to stop the automobile
public void stop();
}
//end of iAutomobile.java