@matfah/

Climbing Club FR 2012

Java

No description

fork
loading
Files
  • Main.java
  • ClimbInfo.java
  • ClimbingClub.java

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5046184253438852","path":"Main.java","file":{"path":"Main.java","content":{"asEncoding":{"base64":"aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLnJlZmxlY3QuKjsKCnB1YmxpYyBjbGFzcyBNYWluIHsKICAKICBwcml2YXRlIHN0YXRpYyBTdHJpbmdbXSBuYW1lcyA9IHsiQSIsICJCIiwgIkMiLCAiRCIsICJFIiwgIkYifTsKCiAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgdGVzdEFkZENsaW1iUGFydEEoKTsKICAgIFN5c3RlbS5vdXQucHJpbnRsbigiYWRkQ2xpbWIoKSBQYXJ0IEEuLi4gcGFzc2VkISIpOwogICAgCiAgICB0ZXN0QWRkQ2xpbWJQYXJ0QigpOwogICAgU3lzdGVtLm91dC5wcmludGxuKCJhZGRDbGltYigpIFBhcnQgQi4uLiBwYXNzZWQhIik7CiAgICAKICAgIHRlc3RQYXJ0QygpOwogICAgU3lzdGVtLm91dC5wcmludGxuKCJBbGwgdGVzdHMgcGFzc2VkISIpOwogIH0KICAKICBwdWJsaWMgc3RhdGljIHZvaWQgdGVzdEFkZENsaW1iUGFydEEoKSB7CiAgICAKICAgIEZpZWxkIGNsaW1iTGlzdEZpZWxkID0gbnVsbDsKICAgIAogICAgdHJ5IHsKICAgICAgY2xpbWJMaXN0RmllbGQgPSBDbGltYmluZ0NsdWIuY2xhc3MuZ2V0RGVjbGFyZWRGaWVsZCgiY2xpbWJMaXN0Iik7CiAgICB9ICAKICAgIGNhdGNoKEV4Y2VwdGlvbiBlKSB7CiAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRXJyb3IgYWNjZXNzaW5nIGNsaW1iTGlzdCBpbnN0YW5jZSB2YXJpYWJsZSIpOwogICAgICBTeXN0ZW0uZXhpdCgwKTsKICAgIH0gCiAgICBjbGltYkxpc3RGaWVsZC5zZXRBY2Nlc3NpYmxlKHRydWUpOwogICAgCiAgICAKICAgIGZvcihpbnQgaSA9IDA7IGkgPCAxMDsgaSsrKSB7CiAgICAgIAogICAgICBDbGltYmluZ0NsdWIgY2x1YiA9IG5ldyBDbGltYmluZ0NsdWIoKTsKICAgICAgCiAgICAgIExpc3Q8Q2xpbWJJbmZvPiBsaXN0ID0gbmV3IEFycmF5TGlzdDxDbGltYkluZm8+KCk7IAogICAgICAKICAgICAgZm9yKGludCBqID0gMDsgaiA8IGk7IGorKykgewogICAgICAgIGxpc3QuYWRkKG5ldyBDbGltYkluZm8obmFtZXNbKGludCkoTWF0aC5yYW5kb20oKSpuYW1lcy5sZW5ndGgpXSwgKGludCkoTWF0aC5yYW5kb20oKSoxMDApKzEwKSk7CiAgICAgIH0KICAgICAgCiAgICAgIFN0cmluZyBwcmVMaXN0ID0gbGlzdC50b1N0cmluZygpOwogICAgICAKICAgICAgdHJ5IHsKICAgICAgICBjbGltYkxpc3RGaWVsZC5zZXQoY2x1YiwgbGlzdCk7CiAgICAgIH0KICAgICAgY2F0Y2goRXhjZXB0aW9uIGUpIHsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkVycm9yIHNldHRpbmcgY2xpbWJMaXN0IGluc3RhbmNlIHZhcmlhYmxlIik7CiAgICAgICAgU3lzdGVtLmV4aXQoMCk7CiAgICAgIH0KICAgICAgCiAgICAgIFN0cmluZyBuYW1lID0gbmFtZXNbKGludCkoTWF0aC5yYW5kb20oKSpuYW1lcy5sZW5ndGgpXTsKICAgICAgaW50IHRpbWUgPSAoaW50KShNYXRoLnJhbmRvbSgpKjEwMCkrMTA7CiAgICAgIAogICAgICB0cnkgewogICAgICAgIGNsdWIuYWRkQ2xpbWJQYXJ0QShuYW1lLCB0aW1lKTsKICAgICAgfQogICAgICBjYXRjaChFeGNlcHRpb24gZSkgewogICAgICAgIF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uZXcgQ2xpbWJpbmdDbHViKCk7CiAgICAgIAogICAgICAgIExpc3Q8Q2xpbWJJbmZvPiBsaXN0ID0gbmV3IEFycmF5TGlzdDxDbGltYkluZm8+KCk7IAogICAgICAgIAogICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBpOyBqKyspIHsKICAgICAgICAgIGxpc3QuYWRkKG5ldyBDbGltYkluZm8obmFtZXNbKGludCkoTWF0aC5yYW5kb20oKSpuYW1lcy5sZW5ndGgpXSwgKGludCkoTWF0aC5yYW5kb20oKSoxMDApKzEwKSk7CiAgICAgICAgfQogICAgICAgIAogICAgICAgIC8vc29ydCBieSBuYW1lCiAgICAgICAgQ29sbGVjdGlvbnMuc29ydChsaXN0LCBuZXcgQ29tcGFyYXRvcjxDbGltYkluZm8+KCkgewogICAgICAgICAgcHVibGljIGludCBjb21wYXJlKENsaW1iSW5mbyBhLCBDbGltYkluZm8gYikgewogICAgICAgICAgICByZXR1cm4gYS5nZXROYW1lKCkuY29tcGFyZVRvKGIuZ2V0TmFtZSgpKTsKICAgICAgICAgIH0KICAgICAgICB9KTsKICAgICAgICAKCiAgICAgICAgU3RyaW5nIHByZUxpc3QgPSBsaXN0LnRvU3RyaW5nKCk7CiAgICAgICAgCiAgICAgICAgTGlzdDxDbGltYkluZm8+IGJhY2t1cCA9IG5ldyBBcnJheUxpc3Q8Q2xpbWJJbmZvPigpOyAKICAgICAgICBmb3IoQ2xpbWJJbmZvIGluZm8gOiBsaXN0KSB7CiAgICAgICAgICBiYWNrdXAuYWRkKGluZm8pOwogICAgICAgIH0KICAgICAgICAKICAgICAgICB0cnkgewogICAgICAgICAgY2xpbWJMaXN0RmllbGQuc2V0KGNsdWIsIGxpc3QpOwogICAgICAgIH0KICAgICAgICBjYXRjaChFeGNlcHRpb24gZSkgewogICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJFcnJvciBzZXR0aW5nIGNsaW1iTGlzdCBpbnN0YW5jZSB2YXJpYWJsZSIpOwogICAgICAgICAgU3lzdGVtLmV4aXQoMCk7CiAgICAgICAgfQogICAgICAgIAogICAgICAgIHRyeSB7CiAgICAgICAgICBjbHViLmFkZENsaW1iUGFydEIobmFtZSwgdGltZSk7CiAgICAgICAgfQogICAgICAgIGNhdGNoKEV4Y2VwdGlvbiBlKSB7CiAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIkVycm9yIGNhbGxpbmcgYWRkQ2xpbWJQYXJ0QigpIik7CiAgICAgICAgICBTeXN0ZW0uZXhpdCgwKTsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgdHJ5IHsKICAgICAgICAgIGxpc3QgPSAoTGlzdDxDbGltYkluZm8+KWNsaW1iTGlzdEZpZWxkLmdldChjbHViKTsKICAgICAgICB9CiAgICAgICAgY2F0Y2goRXhjZXB0aW9uIGUpIHsKICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRXJyb3IgZ2V0dGluZyBjbGltYkxpc3QgaW5zdGFuY2UgdmFyaWFibGUiKTsKICAgICAgICAgIFN5c3RlbS5leGl0KDApOwogICAgICAgIH0KICAgICAgICAKICAgICAgICBpZihsaXN0LnNpemUoKSA9PSAwKSB7CiAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oImFkZENsaW1iUGFydEIoKSBkb2VzIG5vdCBhZGQgYW55dGhpbmcgdG8gdGhlIGxpc3QhIik7CiAgICAgICAgICBTeXN0ZW0uZXhpdCgwKTsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgaWYobGlzdC5zaXplKCkgIT0gYmFja3VwLnNpemUoKSArIDEpIHsKICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiYWRkQ2xpbWJQYXJ0QigpIGRvZXMgbm90IGluY3JlYXNlIHRoZSBsaXN0IHNpemUgYnkgMSEiKTsKICAgICAgICAgIFN5c3RlbS5leGl0KDApOwogICAgICAgIH0KICAgICAgICAKICAgICAgICAvL25vdyB3ZSBuZWVkIHRvIGtub3cgd2hlcmUgdGhleSBhZ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BOIGZvciBubywgdGhlbiBoaXQgdGhlIGVudGVyIGtleS4gICIpOwogICAgU3RyaW5nIGZpcnN0QW5zd2VyID0gc2MubmV4dExpbmUoKTsKICAgIAogICAgU3lzdGVtLm91dC5wcmludGxuKCJcbkRvZXMgdGhpcyBpbXBsZW1lbnRhdGlvbiBvZiB0aGUgZGlzdGluY3RQZWFrTmFtZXMgbWV0aG9kIHdvcmsgYXMgaW50ZW5kZWQgd2hlbiB0aGUgYWRkQ2xpbWIgbWV0aG9kIHN0b3JlcyB0aGUgQ2xpbWJJbmZvIG9iamVjdHMgaW4gYWxwaGFiZXRpY2FsIG9yZGVyIGJ5IG5hbWUgYXMgZGVzY3JpYmVkIGluIHBhcnQgKGIpPyAgVHlwZSBpbiBZIGZvciB5ZXMsIG9yIE4gZm9yIG5vLCB0aGVuIGhpdCB0aGUgZW50ZXIga2V5LiAgIik7CiAgICAKICAgIFN0cmluZyBzZWNvbmRBbnN3ZXIgPSBzYy5uZXh0TGluZSgpOwogICAgCiAgICBpZighZmlyc3RBbnN3ZXIuZXF1YWxzKCJOIikgfHwgIXNlY29uZEFuc3dlci5lcXVhbHMoIlkiKSkgewogICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIk9uZSBvZiB0aG9zZSBhbnN3ZXJzIHdlcmUgbm90IGNvcnJlY3QhIik7CiAgICAgIFN5c3RlbS5leGl0KDApOwogICAgfQogICAgCiAgICAKICB9Cn0="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
import java.util.*;
import java.lang.reflect.*;

public class Main {
  
  private static String[] names = {"A", "B", "C", "D", "E", "F"};

  public static void main(String[] args) {
    testAddClimbPartA();
    System.out.println("addClimb() Part A... passed!");
    
    testAddClimbPartB();
    System.out.println("addClimb() Part B... passed!");
    
    testPartC();
    System.out.println("All tests passed!");
  }
  
  public static void testAddClimbPartA() {
    
    Field climbListField = null;
    
    try {
      climbListField = ClimbingClub.class.getDeclaredField("climbList");
    }  
    catch(Exception e) {
      System.out.println("Error accessing climbList instance variable");
      System.exit(0);
    } 
    climbListField.setAccessible(true);
    
    
    for(int i = 0; i < 10; i++) {
      
      ClimbingClub club = new ClimbingClub();
      
      List<ClimbInfo> list = new ArrayList<ClimbInfo>(); 
      
      for(int j = 0; j < i; j++) {
        list.add(new ClimbInfo(names[(int)(Math.random()*names.length)], (int)(Math.random()*100)+10));
      }
      
      String preList = list.toString();
      
      try {
        climbListField.set(club, list);
      }
      catch(Exception e) {
        System.out.println("Error setting climbList instance variable");
        System.exit(0);
      }
      
      String name = names[(int)(Math.random()*names.length)];
      int time = (int)(Math.random()*100)+10;
      
      try {
        club.addClimbPartA(name, time);
      }
      catch(Exception e) {
        System.out.println("Error calling addClimbPartA()");
        System.exit(0);
      }
      
      try {
        list = (List<ClimbInfo>)climbListField.get(club);
      }
      catch(Exception e) {
        System.out.println("Error getting climbList instance variable");
        System.exit(0);
      }
      
      if(list.size() == 0) {
        System.out.println("addClimbPartA() does not add anything to the list!");
        System.exit(0);
      }
      
      ClimbInfo last = list.remove(list.size()-1);
      
      if(!list.toString().equals(preList)) {
        System.out.println("addClimbPartA() should not modify the beginning of the list!");
        System.exit(0);
      }
      
      if(last == null) {
        System.out.println("addClimbPartA() should not add a null value to the list!");
        System.exit(0);
      }
      
      if(!last.getName().equals(name) || last.getTime() != time) {
        System.out.println("addClimbPartA() adds a ClimbInfo to the end of the list with the wrong values!");
        System.exit(0);
      }
    }
  }
  
  public static void testAddClimbPartB() {
    
    Field climbListField = null;
    
    try {
      climbListField = ClimbingClub.class.getDeclaredField("climbList");
    }  
    catch(Exception e) {
      System.out.println("Error accessing climbList instance variable");
      System.exit(0);
    } 
    climbListField.setAccessible(true);
    
    
    for(int i = 0; i < 10; i++) {
      
      //try for each name so we can try all the possible boundary cases
      for(String name: names) {
        int time = (int)(Math.random()*100)+10;
        
        ClimbingClub club = new ClimbingClub();
      
        List<ClimbInfo> list = new ArrayList<ClimbInfo>(); 
        
        for(int j = 0; j < i; j++) {
          list.add(new ClimbInfo(names[(int)(Math.random()*names.length)], (int)(Math.random()*100)+10));
        }
        
        //sort by name
        Collections.sort(list, new Comparator<ClimbInfo>() {
          public int compare(ClimbInfo a, ClimbInfo b) {
            return a.getName().compareTo(b.getName());
          }
        });
        

        String preList = list.toString();
        
        List<ClimbInfo> backup = new ArrayList<ClimbInfo>(); 
        for(ClimbInfo info : list) {
          backup.add(info);
        }
        
        try {
          climbListField.set(club, list);
        }
        catch(Exception e) {
          System.out.println("Error setting climbList instance variable");
          System.exit(0);
        }
        
        try {
          club.addClimbPartB(name, time);
        }
        catch(Exception e) {
          System.out.println("Error calling addClimbPartB()");
          System.exit(0);
        }
        
        try {
          list = (List<ClimbInfo>)climbListField.get(club);
        }
        catch(Exception e) {
          System.out.println("Error getting climbList instance variable");
          System.exit(0);
        }
        
        if(list.size() == 0) {
          System.out.println("addClimbPartB() does not add anything to the list!");
          System.exit(0);
        }
        
        if(list.size() != backup.size() + 1) {
          System.out.println("addClimbPartB() does not increase the list size by 1!");
          System.exit(0);
        }
        
        //now we need to know where they added
        int insertPos = 0;
        while(insertPos < backup.size() && list.get(insertPos) != null && list.get(insertPos).getName().equals(backup.get(insertPos).getName()) && list.get(insertPos).getTime() == backup.get(insertPos).getTime()) {
            insertPos++;
        }
        
        ClimbInfo insertedValue = list.remove(insertPos);
        
        if(!list.toString().equals(preList)) {
          System.out.println("addClimbPartB() should not modify the order or values already in the list!");
          System.exit(0);
        }
        
        if(insertedValue == null) {
          System.out.println("addClimbPartB() should not add a null value to the list!");
          System.exit(0);
        }
        
        if(!insertedValue.getName().equals(name) || insertedValue.getTime() != time) {
          System.out.println("addClimbPartB() adds a ClimbInfo to the end of the list with the wrong values!");
         System.exit(0);
       }
        
        if(insertPos > 0 && list.get(insertPos-1).getName().compareTo(insertedValue.getName()) > 0 ||
           insertPos < list.size() && list.get(insertPos).getName().compareTo(insertedValue.getName()) < 0){
          System.out.println("addClimbPartB() adds a ClimbInfo to the list at the wrong spot!");
          System.exit(0);
        }
      }
    }
  }
  
  public static void testPartC() {
    
    Scanner sc = new Scanner(System.in);
    
    System.out.println("Does this implementation of the distinctPeakNames method work as intended when the addClimb method stores the ClimbInfo objects in the order they were added as described in part (a)?  Type in Y for yes, or N for no, then hit the enter key.  ");
    String firstAnswer = sc.nextLine();
    
    System.out.println("\nDoes this implementation of the distinctPeakNames method work as intended when the addClimb method stores the ClimbInfo objects in alphabetical order by name as described in part (b)?  Type in Y for yes, or N for no, then hit the enter key.  ");
    
    String secondAnswer = sc.nextLine();
    
    if(!firstAnswer.equals("N") || !secondAnswer.equals("Y")) {
      System.out.println("One of those answers were not correct!");
      System.exit(0);
    }
    
    
  }
}