Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
project_2:account [2012/07/10 16:19] t.amrutha |
project_2:account [2012/07/10 16:20] (current) t.amrutha |
||
---|---|---|---|
Line 4: | Line 4: | ||
1 //constructor | 1 //constructor | ||
2 | 2 | ||
- | 3 /* | + | 3 /** |
4 * @Generated-Summary : sets name to the input nm string. | 4 * @Generated-Summary : sets name to the input nm string. | ||
5 * <Gen-End> | 5 * <Gen-End> | ||
6 */ | 6 */ | ||
- | |||
7 public Account(String nm,double amnt ) { | 7 public Account(String nm,double amnt ) { | ||
- | |||
8 amount=amnt; | 8 amount=amnt; | ||
- | |||
9 name=nm; | 9 name=nm; | ||
- | |||
10 } | 10 } | ||
Line 39: | Line 35: | ||
1 //functions | 1 //functions | ||
2 | 2 | ||
- | 3 /* | + | 3 /** |
4 * @Generated-Summary : adds the input money to amount. | 4 * @Generated-Summary : adds the input money to amount. | ||
5 * <Gen-End> | 5 * <Gen-End> | ||
6 */ | 6 */ | ||
- | |||
7 synchronized void depsite(double money){ | 7 synchronized void depsite(double money){ | ||
- | |||
8 amount+=money; | 8 amount+=money; | ||
- | |||
9 } | 9 } | ||
Line 68: | Line 61: | ||
-----Account.withdraw(D)V C-Units=1 | -----Account.withdraw(D)V C-Units=1 | ||
- | 1 /* | + | 1 /** |
2 * @Generated-Summary : froms the input money null amount. | 2 * @Generated-Summary : froms the input money null amount. | ||
3 * <Gen-End> | 3 * <Gen-End> | ||
4 */ | 4 */ | ||
- | |||
5 synchronized void withdraw(double money){ | 5 synchronized void withdraw(double money){ | ||
- | |||
6 amount-=money; | 6 amount-=money; | ||
- | |||
7 } | 7 } | ||
Line 97: | Line 87: | ||
-----Account.transfer(QAccount;D)V C-Units=7 | -----Account.transfer(QAccount;D)V C-Units=7 | ||
- | 1 /* | + | 1 /** |
2 * @Generated-Summary : froms the input mn null amount. adds the input mn to amount. adds the input mn to amount. | 2 * @Generated-Summary : froms the input mn null amount. adds the input mn to amount. adds the input mn to amount. | ||
3 * | 3 * | ||
Line 104: | Line 94: | ||
6 * <Gen-End> | 6 * <Gen-End> | ||
7 */ | 7 */ | ||
- | |||
8 synchronized void transfer(Account ac,double mn){ | 8 synchronized void transfer(Account ac,double mn){ | ||
- | |||
9 amount-=mn; | 9 amount-=mn; | ||
- | |||
10 //System.out.println("ac.amount is $"+ac.amount); | 10 //System.out.println("ac.amount is $"+ac.amount); | ||
- | |||
11 if (name.equals("D")) { | 11 if (name.equals("D")) { | ||
- | |||
12 System.out.println("unprotected"); | 12 System.out.println("unprotected"); | ||
- | |||
13 ac.amount+=mn;//no aquire for the other lock!! | 13 ac.amount+=mn;//no aquire for the other lock!! | ||
- | |||
14 //+= might cause problem --it is not atomic. | 14 //+= might cause problem --it is not atomic. | ||
- | |||
15 } else { | 15 } else { | ||
- | |||
16 //System.out.println("protected"); | 16 //System.out.println("protected"); | ||
- | |||
17 synchronized (ac) { ac.amount+=mn; } | 17 synchronized (ac) { ac.amount+=mn; } | ||
- | |||
18 } | 18 } | ||
- | |||
19 } | 19 } | ||
Line 180: | Line 158: | ||
5 */ | 5 */ | ||
6 public ManageAccount(String name,double amount) { | 6 public ManageAccount(String name,double amount) { | ||
- | |||
7 account=new Account(name,amount); | 7 account=new Account(name,amount); | ||
- | |||
8 i=accNum; | 8 i=accNum; | ||
- | |||
9 accounts[i]=account; | 9 accounts[i]=account; | ||
- | |||
10 accNum=(accNum+1)%num;//the next index in a cyclic order | 10 accNum=(accNum+1)%num;//the next index in a cyclic order | ||
- | |||
11 } | 11 } | ||
Line 258: | Line 231: | ||
-----ManageAccount.printAllAccounts()V C-Units=2 | -----ManageAccount.printAllAccounts()V C-Units=2 | ||
- | 1 /* | + | 1 /** |
2 * @Generated-Summary : prints Account. | 2 * @Generated-Summary : prints Account. | ||
3 * <Gen-End> | 3 * <Gen-End> | ||
Line 287: | Line 260: | ||
-----Main.main([QString;)V C-Units=22 | -----Main.main([QString;)V C-Units=22 | ||
- | 1 /* | + | 1 /** |
2 * @Generated-Summary : joins Thread. | 2 * @Generated-Summary : joins Thread. | ||
3 * | 3 * |