projects
/
IRC.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cc5677c
)
extensions to library classes
author
jjenista
<jjenista>
Thu, 26 Feb 2009 23:21:27 +0000
(23:21 +0000)
committer
jjenista
<jjenista>
Thu, 26 Feb 2009 23:21:27 +0000
(23:21 +0000)
Robust/src/ClassLibrary/Character.java
patch
|
blob
|
history
Robust/src/ClassLibrary/HashMapIterator.java
patch
|
blob
|
history
Robust/src/ClassLibrary/LinkedList.java
patch
|
blob
|
history
Robust/src/ClassLibrary/String.java
patch
|
blob
|
history
Robust/src/Tests/StringTest.java
patch
|
blob
|
history
diff --git
a/Robust/src/ClassLibrary/Character.java
b/Robust/src/ClassLibrary/Character.java
index f1ca673a85bbfd09b670ed3f6d2ec778ff3fec73..2a12c8c1d9b4b8f5cfba9ee33442e2e2269b310a 100644
(file)
--- a/
Robust/src/ClassLibrary/Character.java
+++ b/
Robust/src/ClassLibrary/Character.java
@@
-14,4
+14,18
@@
public class Character {
}
return -1;
}
}
return -1;
}
+
+ char value;
+
+ public Character( char c ) {
+ value = c;
+ }
+
+ public Character( Character c ) {
+ value = c.value;
+ }
+
+ public String toString() {
+ return ""+value;
+ }
}
}
diff --git
a/Robust/src/ClassLibrary/HashMapIterator.java
b/Robust/src/ClassLibrary/HashMapIterator.java
index 48dc913711c4d2ef0feec5c0b558638ea8361016..e297cf5f948760ff8bee10b308fe11ceb52767fe 100644
(file)
--- a/
Robust/src/ClassLibrary/HashMapIterator.java
+++ b/
Robust/src/ClassLibrary/HashMapIterator.java
@@
-1,4
+1,4
@@
-class HashMapIterator {
+class HashMapIterator
extends Iterator
{
HashMap map;
int type;
int bin;
HashMap map;
int type;
int bin;
@@
-43,4
+43,9
@@
class HashMapIterator {
return o;
} else System.error();
}
return o;
} else System.error();
}
+
+ public void remove() {
+ System.out.println( "HashMapIterator.remove() not implemented." );
+ System.exit( -1 );
+ }
}
}
diff --git
a/Robust/src/ClassLibrary/LinkedList.java
b/Robust/src/ClassLibrary/LinkedList.java
index b4f26e69a5e935d3527ef3a45014c06af7215c60..98701fba4a47145d36fbdd734e5b474e7a391b03 100644
(file)
--- a/
Robust/src/ClassLibrary/LinkedList.java
+++ b/
Robust/src/ClassLibrary/LinkedList.java
@@
-59,6
+59,10
@@
public class LinkedList {
return size;
}
return size;
}
+ public boolean isEmpty() {
+ return size == 0;
+ }
+
public Object clone() {
System.out.println( "LinkedList.clone() not implemented." );
System.exit(-1);
public Object clone() {
System.out.println( "LinkedList.clone() not implemented." );
System.exit(-1);
@@
-105,11
+109,12
@@
public class LinkedList {
getLast();
}
getLast();
}
- public
void
removeFirst() {
+ public
Object
removeFirst() {
if( head == null ) {
System.out.println( "LinkedList: illegal removeFirst()" );
System.exit(-1);
}
if( head == null ) {
System.out.println( "LinkedList: illegal removeFirst()" );
System.exit(-1);
}
+ Object o = head.element;
head = head.next;
if( head != null ) {
head.prev = null;
head = head.next;
if( head != null ) {
head.prev = null;
@@
-117,13
+122,15
@@
public class LinkedList {
tail = null;
}
size--;
tail = null;
}
size--;
+ return o;
}
}
- public
void
removeLast() {
+ public
Object
removeLast() {
if( tail == null ) {
System.out.println( "LinkedList: illegal removeLast()" );
System.exit(-1);
}
if( tail == null ) {
System.out.println( "LinkedList: illegal removeLast()" );
System.exit(-1);
}
+ Object o = tail.element;
tail = tail.prev;
if( tail != null ) {
tail.next = null;
tail = tail.prev;
if( tail != null ) {
tail.next = null;
@@
-131,6
+138,7
@@
public class LinkedList {
head = null;
}
size--;
head = null;
}
size--;
+ return o;
}
public void remove( Object o ) {
}
public void remove( Object o ) {
diff --git
a/Robust/src/ClassLibrary/String.java
b/Robust/src/ClassLibrary/String.java
index a06028bff66f6f76bf8c5c7bcdb097bcc9576000..dab2feeb26c6c36ff3cbf1b55bc73b6f0704182e 100644
(file)
--- a/
Robust/src/ClassLibrary/String.java
+++ b/
Robust/src/ClassLibrary/String.java
@@
-135,6
+135,18
@@
public class String {
return new String(buffer);
}
return new String(buffer);
}
+ public String toLowerCase() {
+ char[] buffer=new char[count];
+ for(int i=0; i<count; i++) {
+ char x=charAt(i);
+ if (x>='A'&&x<='Z') {
+ x=(char) ((x-'A')+'a');
+ }
+ buffer[i]=x;
+ }
+ return new String(buffer);
+ }
+
public int indexOf(int ch) {
return this.indexOf(ch, 0);
}
public int indexOf(int ch) {
return this.indexOf(ch, 0);
}
diff --git
a/Robust/src/Tests/StringTest.java
b/Robust/src/Tests/StringTest.java
index 30d4ecd0d3758226f4764c7de6fe257538ca7970..2bc805df65070f32244f96ce1c855e65ee998c7d 100644
(file)
--- a/
Robust/src/Tests/StringTest.java
+++ b/
Robust/src/Tests/StringTest.java
@@
-9,5
+9,10
@@
class StringTest {
System.printString(a.subString(3));
System.printString(a.subString(3,6));
System.printString("\n");
System.printString(a.subString(3));
System.printString(a.subString(3,6));
System.printString("\n");
+
+ String b = "Danger iN cAVErn_coVE";
+ System.out.println( "normal: "+b );
+ System.out.println( "upper: "+b.toUpperCase() );
+ System.out.println( "lower: "+b.toLowerCase() );
}
}
}
}