Biblioteca Java - Blame information for rev 38
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
38 | mihai | 1 | public class CoffeTest { |
2 | |||
3 | public static void main(String[] args) { | ||
4 | CoffeMaker maker1 = new CoffeMaker(); | ||
5 | |||
6 | Coffee[] pachet = new Coffee[10]; | ||
7 | for (int i = 0; i < pachet.length; i++) { | ||
8 | pachet[i] = maker1.getCofee(); | ||
9 | } | ||
10 | |||
11 | for (int i = 0; i < pachet.length; i++) { | ||
12 | pachet[i].drinkCofee(); | ||
13 | } | ||
14 | |||
15 | } | ||
16 | } | ||
17 | |||
18 | class CoffeMaker{ | ||
19 | CaffeineTank ctank = new CaffeineTank(); | ||
20 | WaterTank wtank = new WaterTank(); | ||
21 | CoffeMaker(){ | ||
22 | System.out.println("New cofee maker created."); | ||
23 | } | ||
24 | Coffee getCofee(){ | ||
25 | int w = wtank.getIngredient(); | ||
26 | int c = ctank.getIngredient(); | ||
27 | return new Coffee(w,c); | ||
28 | } | ||
29 | } | ||
30 | |||
31 | class CaffeineTank{ | ||
32 | CaffeineTank(){ | ||
33 | System.out.println("New coffeine tank created."); | ||
34 | } | ||
35 | int getIngredient(){ | ||
36 | return (int)(Math.random()*10); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | class WaterTank{ | ||
41 | WaterTank(){ | ||
42 | System.out.println("New water tank created."); | ||
43 | } | ||
44 | int getIngredient(){ | ||
45 | return (int)(Math.random()*40); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | class Coffee { | ||
50 | int water; | ||
51 | int caffeine; | ||
52 | Coffee(int water, int caffeine){ | ||
53 | this.water = water;this.caffeine= caffeine; | ||
54 | } | ||
55 | void drinkCofee(){ | ||
56 | System.out.println("Drink cofee [water="+water+":coffe="+ caffeine+"]"); | ||
57 | } | ||
58 | } |