~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/song/models/Chord.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2007-02-04 01:41:23 UTC
  • Revision ID: james.westby@ubuntu.com-20070204014123-9pv7okph0iaiqkvw
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Created on 29-dic-2005
 
3
 *
 
4
 * TODO To change the template for this generated file go to
 
5
 * Window - Preferences - Java - Code Style - Code Templates
 
6
 */
 
7
package org.herac.tuxguitar.song.models;
 
8
/**
 
9
 * @author julian
 
10
 *
 
11
 * TODO To change the template for this generated type comment go to
 
12
 * Window - Preferences - Java - Code Style - Code Templates
 
13
 */
 
14
public class Chord {
 
15
        private String name;
 
16
    private int[] strings;
 
17
    
 
18
    public Chord(int length){
 
19
        this.strings = new int[length];
 
20
        for(int i = 0;i < this.strings.length;i++){
 
21
            this.strings[i] = -1;
 
22
        }
 
23
    }    
 
24
    
 
25
    public void addFretValue(int string,int fret){
 
26
        if(string >= 0 && string < this.strings.length){
 
27
                this.strings[string] = fret;
 
28
        }
 
29
    }
 
30
 
 
31
    public int getFretValue(int string){
 
32
        if(string >= 0 && string < this.strings.length){
 
33
                return this.strings[string];
 
34
        }
 
35
        return -1;
 
36
    }
 
37
    
 
38
    public int[] getStrings() {
 
39
        return strings;
 
40
    }
 
41
    public void setStrings(int[] strings) {
 
42
        this.strings = strings;
 
43
    }
 
44
    
 
45
    public int count(){
 
46
        int values = 0;
 
47
        for(int i = 0;i < this.strings.length;i++){
 
48
            if(this.strings[i] >= 0){
 
49
                values ++;
 
50
            }
 
51
        }      
 
52
        return values;
 
53
    }
 
54
 
 
55
        public String getName() {
 
56
                return name;
 
57
        }
 
58
 
 
59
        public void setName(String name) {
 
60
                this.name = name;
 
61
        }
 
62
        
 
63
        
 
64
        public Object clone(){
 
65
                Chord chord = new Chord(this.strings.length);
 
66
                chord.setName(this.name);
 
67
                for(int i = 0;i < chord.strings.length;i++){
 
68
                        chord.strings[i] = this.strings[i];
 
69
                }
 
70
                return chord;
 
71
        }
 
72
}