|
Post by CooLiBoP on Oct 28, 2001 14:46:02 GMT -5
Here's a good test for Number3Print.java:
public class Number3PrintTest { public static void main(String[] args){ Number3Print.printIntsWith3(1,100); } }
|
|
|
Post by CooLiBoP on Oct 28, 2001 14:47:10 GMT -5
Here's a good test for CapitalOne: public class CapitalOneTest { public static void main(String[] args){ System.out.println(CapitalOne.extractCapitals("AaBbCcDdeEfFgGhHiIjJ")); } }
|
|
|
Post by Sky on Oct 29, 2001 23:55:28 GMT -5
i think to test Number3Print...u should also consider testing negative integers...ie the parameter could be (-50,50) it really depends on your code...for me...i have to do some modifications in order to have it works for negative #s.
|
|
|
Post by Majin_Blues on Oct 30, 2001 16:22:18 GMT -5
in regards to Number3Print
try testing for a large interval... a good test is say 1-400
that way, it'll test everything in the 300's... make careful note of where there's more than one "3" in the number... it might print it more than once...
|
|
|
Post by BlingBling on Oct 30, 2001 19:54:21 GMT -5
I used these 2 classes to test CapitalOne and CapitalTwo, just compile, run, type in whatever string you want passed to the methods, and when your done enter quit.
import java.io.*; class CapitalOneTest{ public static void main(String[] args) throws IOException{ BufferedReader buff; buff = new BufferedReader(new InputStreamReader(System.in));
for (String s = buff.readLine() ; !s.equals("quit") ; s = buff.readLine()){ System.out.println(CapitalOne.extractCapitals(s)); } } }
import java.io.*; class CapitalTwoTest{ public static void main(String[] args) throws IOException{ BufferedReader buff; buff = new BufferedReader(new InputStreamReader(System.in));
for (String s = buff.readLine() ; !s.equals("quit") ; s = buff.readLine()){ System.out.println(CapitalTwo.extractPrecededByCapital(s)); } } }
|
|
KweLi
Full Member
Posts: 29
|
Post by KweLi on Nov 6, 2001 23:01:29 GMT -5
I've got a question for anyone that can answer it. i used CooLiBoT's test program and my program works fine (thanks by the way). But does know if the the program is supposed to print characters like "&" ? cuss mine printed out all the capitals and the "&" symbol.
|
|
|
Post by Majin_Blues on Nov 7, 2001 7:07:10 GMT -5
i don't think it's supposed to do that... CapitalOne outputs only capital letters, right?
but if testing for capitalTwo, the & sign should be there... it says characters... so that includes any funny characters, numbers, spaces, etc.
|
|
|
Post by Brutal_Chicken on Nov 7, 2001 16:21:58 GMT -5
It could be that you did something like:
word.charAt(index) == word.toUpperCase().charAt(index)
Where you're comparing if the letters equal to it's upper cased counterpart. This way doesn't allow for other characters since a "&" is the same whether or not you uppercased it.
If you're speaking about CapitalTwo then "&" must be before a capital.
|
|
Kamui
Junior Member
Posts: 6
|
Post by Kamui on Nov 7, 2001 18:02:50 GMT -5
Then is there a way to ignore the funny characters(ie. %, &, #, etc) in CapitalOne and CapitalTwo?
|
|
|
Post by Majin_Blues on Nov 7, 2001 19:01:06 GMT -5
yep.. either limit the range of characters you're looking for, or use some special method in the char class or something...
i did it the long way and limited it manually...
|
|
|
Post by Sky on Nov 7, 2001 19:57:13 GMT -5
i did it Brutal's way too...just do a bit more to the comparing condition and it will work just fine...use the isLetter method from the Character Class ...something like: word.charAt(index) == word.toUpperCase().charAt(index) && Character.isLetter(s.charAt(index))
Character Class is very useful...a better way to do it is u can just use the isUpperCase method to replace that long line instead
|
|
|
Post by Sky on Nov 7, 2001 19:59:33 GMT -5
Just to remind everyone...the newsgroup said for L1...the user can just press enter...make sure your program work for that
|
|
|
Post by Brutal_Chicken on Nov 7, 2001 21:01:19 GMT -5
Oh yeah, some people at the CDF didn't know how to use the Character class. Not like I know how but I have a rudimentary (read: jack-shit) knowledge of it.
It's quite simple;
Character.isUpperCase(char)
Now for char you can do something like:
someString.toUpperCase().charAt(index)
This way you don't have to worry about "&, %" and stuff. But for CapitalTwo I would suggest just sticking with the more general one since you're only checking cases, then flip the cases and leave the symbols untouched. No real conflict since if you try to upper/lower case "&" it's still the same thing. I better right that in the comments or my TA might subtract marks for laziness... I mean "style".
|
|
|
Post by Dante on Nov 8, 2001 20:52:29 GMT -5
Brutal_Chicken, thanks greatly for that above. It's helped me a lot today.
just that: Character.isUpperCase(char) helped.
You see, the API is all great but sometimes, it's hard to figure out how/what context to type it all in as in the code.
|
|