File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed 
tp3/src/main/kotlin/fmt/kotlin/fundamentals Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ package  fmt.kotlin.fundamentals 
2+ 
3+ class  Cellar  private constructor(
4+     ownerName :  String ,
5+     private  var  wineBarrels :  List <WineBarrel >,
6+ ) {
7+     constructor (ownerName:  String ) :  this (ownerName, listOf ())
8+ 
9+     val  totalWineCapacityInLiters:  Int 
10+         get() {
11+             var  totalCapacity =  0 
12+ 
13+             for  (wineBarrel in  wineBarrels) {
14+                 totalCapacity + =  wineBarrel.capacityInLiters
15+             }
16+ 
17+             return  totalCapacity
18+         }
19+ 
20+     var  cellarName =  " Cave de "   +  ownerName
21+         set(ownerName) {
22+             field =  " Cave de "   +  ownerName
23+         }
24+ 
25+     fun  addBarrels (wineBarrels :  List <WineBarrel >) {
26+         this .wineBarrels =  this .wineBarrels.plus(wineBarrels)
27+     }
28+ 
29+     fun  age (monthsNumber :  Int ) {
30+         for  (wineBarrel in  wineBarrels) {
31+             wineBarrel.age(monthsNumber)
32+         }
33+     }
34+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ class WineBarrel private constructor(
44    val  capacityInLiters :  Int  = 225 ,
55    private  var  wineAgeInMonths :  Int 
66) {
7+     fun  age (monthsNumber :  Int ) {
8+         wineAgeInMonths + =  monthsNumber
9+     }
10+ 
711    constructor (capacityInLiters:  Int  =  225 ) :  this (capacityInLiters, 0 )
812
913    constructor (capacityInLiters:  Int  =  225 , wineBarrel:  WineBarrel ) :  this (
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments