Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Software Development
Tag Cloud
access audio black screen blue screen bsod connection crash dell desktop drivers dvd email error excel excel 2003 firefox hard drive hardware hdmi hijackthis internet itunes keyboard laptop malware monitor motherboard network networking outlook problem ram recovery router screen slow sound spyware tdlwsp.dll trojan upgrade video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
DYS's "in need of Java help" never ending thread

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
DYS's Avatar
DYS DYS is offline
Senior Member with 363 posts.
 
Join Date: Dec 2008
Experience: Beginner
07-Nov-2009, 01:35 PM #1
DYS's "in need of Java help" never ending thread
Hi there.

As some may remember I used to come here for a lot of help with Java. Sadly, I've come back for more help - I hope some people more clued up on the subject than me can help me out. I'd always try and help others out but I'm just not that good at it.

Anyway, I'm now in my second year of university, and my new Java teacher swears by making Tester classes for any Java class files we make.

So, what I need to know is is there any certain requirements a Tester class needs? I know that it would need a main method, as it would be the Java class that is run.
I really don't know how to link the Tester class and the initial class together in order to run properly.

This is a class I found in a textbook earlier and got to run, however, it's just one initial class.

This class generates a random number from 0 and the size of each word list array and then picks a word at random from each list to generate a sentence which is printed to screen:

Code:
public class PhraseOMatic
{
    public static void main (String[] args)
    {
        //Makes the three lists of words
        String[] wordListOne = {"24/7", "multi-Tier", "30,000 foot", "B-to-B", "win-win", "front-end",
                                "web-based", "pervasive", "smart", "six-sigma", "critical-path", "dynamic"};
        
        String[] wordListTwo = {"empowered", "sticky", "value-added", "oriented", "centric", "distributed",
                                "clustered", "branded", "outside-the-box", "positioned", "networked", "focused",
                                "leveraged", "aligned", "targeted", "shared", "cooperative", "accelerated"};
                                
        String[] wordListThree = {"process", "tipping-point", "solution", "architecture", "core competency",
                                  "strategy", "mindshare", "portal", "space", "vision", "paradigm", "mission"};
                                  
        //Finds out how many words are in each list of words
        int oneLength = wordListOne.length;
        int twoLength = wordListTwo.length;
        int threeLength = wordListThree.length;
        
        //Calculations to generate the three random numbers
        int rand1 = (int) (Math.random() * oneLength);
        int rand2 = (int) (Math.random() * twoLength);
        int rand3 = (int) (Math.random() * threeLength);
        
        //Here, the phrase is built
        String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
        
        //Prints out the phrase to screen
        System.out.println("What we need is a " + phrase + ".");
    }
}
Now if I were to create a Tester class for this class, how the heck would I go about doing it?

I hope people understand where I'm coming from here.

Thanks very much.
JimmySeal's Avatar
Senior Member with 206 posts.
 
Join Date: Sep 2007
Experience: Getting there
08-Nov-2009, 08:18 PM #2
I think you're best off asking your teacher for a more specific description of what he or she expects a tester class to do. I don't think there is any standard definition for what a tester class is or does.

But generally, in order to have a tester class, you must have something that is capable of being tested. That is, one or more classes with various methods, inputs and outputs. What you've shown up there is a class with just a main() method that doesn't use the command line input, so there's not any testing you can do with it besides running it from the command line.
DYS's Avatar
DYS DYS is offline
Senior Member with 363 posts.
 
Join Date: Dec 2008
Experience: Beginner
10-Nov-2009, 12:25 PM #3
Hmm... seems he's in his own little world then?

Anyway, I've been working on my Javaness the past few days, and I think I'm making a breakthrough.
He likes to use Getters and Setters in the initial Java files, and then the main method is in the Tester class, as that is the run that is run.

I've been working on a program this weekend that I've just done to try and help myself learn.
It all works, but I just have a semantic error which I'm trying to get around.

Once I've completed it I'll post it here just to show what sort of stuff my teacher expects.

Thanks for your reply
Reply Bookmark and Share

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 02:14 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.