-
Notifications
You must be signed in to change notification settings - Fork 1
/
Expense.java
53 lines (46 loc) · 901 Bytes
/
Expense.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package Daily1;
public class Expense extends Data{
private ExpenseCategory expense_category;
public Expense(){
super();
expense_category = ExpenseCategory.ANONYMOUS;
}
public Expense(String description){
super(description);
int j=1;
int s=5;
for(ExpenseCategory i:ExpenseCategory.values())
{
System.out.println(j+" "+i);
j=j+1;
}
while(s>4)
{
System.out.println("Enter a number between 1 and 4");
s=sc.nextInt();
}
switch(s)
{
case 1:
expense_category = ExpenseCategory.CASH;
break;
case 2:
expense_category = ExpenseCategory.CARD;
break;
case 3:
expense_category = ExpenseCategory.STATIONARY;
break;
case 4:
expense_category = ExpenseCategory.ANONYMOUS;
break;
default:
}
}
}
enum ExpenseCategory {
CASH(1),CARD(2),STATIONARY(3),ANONYMOUS(4);
private int value;
private ExpenseCategory(int value){
this.value=value;
}
}