CTC++ Coverage Report - Execution Profile    #2/32

Directory Summary | Files Summary | Functions Summary | Execution Profile
To files: First | Previous | Next | Last | Index | No Index


File: BubbleManager.java
Instrumentation mode: function-decision-multicondition
TER: 83 % ( 20/ 24)

Start/ End/    
True False - Line Source

  1 /* 
  2  *                 [[ Frozen-Bubble ]] 
  3  * 
  4  * Copyright (c) 2000-2003 Guillaume Cottenceau. 
  5  * Java sourcecode - Copyright (c) 2003 Glenn Sanson. 
  6  * 
  7  * This code is distributed under the GNU General Public License  
  8  * 
  9  * This program is free software; you can redistribute it and/or 
  10  * modify it under the terms of the GNU General Public License 
  11  * version 2, as published by the Free Software Foundation. 
  12  *  
  13  * This program is distributed in the hope that it will be useful, but 
  14  * WITHOUT ANY WARRANTY; without even the implied warranty of 
  15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
  16  * General Public License for more details. 
  17  *  
  18  * You should have received a copy of the GNU General Public License along 
  19  * with this program; if not, write to the Free Software Foundation, Inc., 
  20  * 675 Mass Ave, Cambridge, MA 02139, USA. 
  21  * 
  22  * 
  23  * Artwork: 
  24  *    Alexis Younes <73lab at free.fr> 
  25  *      (everything but the bubbles) 
  26  *    Amaury Amblard-Ladurantie <amaury at linuxfr.org> 
  27  *      (the bubbles) 
  28  * 
  29  * Soundtrack: 
  30  *    Matthias Le Bidan <matthias.le_bidan at caramail.com> 
  31  *      (the three musics and all the sound effects) 
  32  * 
  33  * Design & Programming: 
  34  *    Guillaume Cottenceau <guillaume.cottenceau at free.fr> 
  35  *      (design and manage the project, whole Perl sourcecode) 
  36  * 
  37  * Java version: 
  38  *    Glenn Sanson <glenn.sanson at free.fr> 
  39  *      (whole Java sourcecode, including JIGA classes  
  40  *             http://glenn.sanson.free.fr/jiga/) 
  41  * 
  42  *          [[ http://glenn.sanson.free.fr/fb/ ]] 
  43  *          [[ http://www.frozen-bubble.org/   ]] 
  44  */ 
  45  
  46 import java.awt.*; 
  47 import java.util.Random; 
  48  
  49 public class BubbleManager 
  50 
  51    int bubblesLeft; 
  52    Image[] bubbles; 
  53    int[] countBubbles; 
  54     
 
369   55    public BubbleManager(Image[] bubbles) 
  56    {    
  57       this.bubbles = bubbles; 
  58       this.countBubbles = new int[bubbles.length]; 
  59       this.bubblesLeft = 0; 
  60    } 
  61     
 
15702   62    public void addBubble(Image bubble) 
  63    { 
  64       countBubbles[findBubble(bubble)]++; 
  65       bubblesLeft++; 
  66    } 
  67     
 
13416   68    public void removeBubble(Image bubble) 
  69    { 
  70       countBubbles[findBubble(bubble)]--; 
  71       bubblesLeft--; 
  72    } 
  73     
 
9661   74    public int countBubbles() 
  75    { 
9661    76       return bubblesLeft; 
  77    } 
  78     
 
10434   79    public int nextBubbleIndex(Random rand) 
  80    { 
  81       int select = rand.nextInt() % bubbles.length; 
  82        
4478 5956   83       if (select < 0) 
  84       { 
  85          select = -select; 
  86       } 
  87  
  88       int count = -1; 
  89       int position = -1; 
  90        
104322 10434   91       while (count != select) 
  92       { 
  93          position++; 
  94           
7650 96672   95          if (position == bubbles.length) 
  96          { 
  97             position = 0; 
  98          } 
  99           
46511 57811   100          if (countBubbles[position] != 0) 
  101          { 
  102             count++; 
  103          } 
  104       } 
  105        
10434    106       return position; 
  107    } 
  108     
 
- 109    public Image nextBubble(Random rand) 
  110    { 
 - 111       return bubbles[nextBubbleIndex(rand)]; 
  112    } 
  113     
 
29118   114    private int findBubble(Image bubble) 
  115    { 
124012 - 116       for (int i=0 ; i<bubbles.length ; i++) 
  117       { 
29118 94894   118          if (bubbles[i] == bubble) 
  119          { 
29118    120             return i; 
  121          } 
  122       } 
  123        
 - 124       return -1; 
  125    } 
  126 }
***TER 83% (20/24) of SOURCE FILE BubbleManager.java

Directory Summary | Files Summary | Functions Summary | Execution Profile
To files: First | Previous | Next | Last | Top | Index | No Index