Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

java help:)

  • 09-04-2010 02:25AM
    #1
    Registered Users, Registered Users 2 Posts: 310 ✭✭


    hey guys can someone give me a hand with this assignment :)

    [FONT=Trebuchet MS, sans-serif]Complete the following class:[/FONT]


    [FONT=Courier New, monospace]class TestWordListMethods[/FONT]
    [FONT=Courier New, monospace]{[/FONT]
    [FONT=Courier New, monospace]private WordList wl = new WordList();[/FONT]

    [FONT=Courier New, monospace]public static void main(String args[])[/FONT]
    [FONT=Courier New, monospace]{[/FONT]
    [FONT=Courier New, monospace]new TestWordListMethods();[/FONT]
    [FONT=Courier New, monospace]} [/FONT]
    [FONT=Courier New, monospace]// Default Constructor[/FONT]
    [FONT=Courier New, monospace]public TestWordListMethods()[/FONT]
    [FONT=Courier New, monospace]{[/FONT]
    [FONT=Courier New, monospace]String longestWord = findLongestWord();[/FONT]
    [FONT=Courier New, monospace]String longestWordA = findLongestWordStartingWith('v');[/FONT]
    [FONT=Courier New, monospace]int averageLetters = findAverageNumberOfLetters();[/FONT]
    [FONT=Courier New, monospace]char mostCommon = findMostCommonLetter();[/FONT]
    [FONT=Courier New, monospace]String[] anagrams = findAllAnagrams("retains");[/FONT]
    [FONT=Courier New, monospace]System.out.println("The longest word is " + longestWord);[/FONT]
    [FONT=Courier New, monospace]System.out.println("The longest word starting with 'v' is " + longestWordA);[/FONT]
    [FONT=Courier New, monospace]System.out.println("The average number of letters is " + averageLetters);[/FONT]
    [FONT=Courier New, monospace]System.out.println("The most common letter is " + mostCommon); [/FONT]
    [FONT=Courier New, monospace]for(int i = 0; i < anagrams.length; i++)[/FONT]
    [FONT=Courier New, monospace]{[/FONT]
    [FONT=Courier New, monospace]System.out.println(anagrams + " is an anagram of retains");[/FONT]
    [FONT=Courier New, monospace]}[/FONT]
    [FONT=Courier New, monospace]} [/FONT]
    [FONT=Courier New, monospace]private String findLongestWord()[/FONT]
    [FONT=Courier New, monospace]{[/FONT]
    [FONT=Courier New, monospace]return null;[/FONT]
    [FONT=Courier New, monospace]}[/FONT]

    [FONT=Courier New, monospace]private String findLongestWordStartingWith(char c)[/FONT]
    [FONT=Courier New, monospace]{[/FONT]
    [FONT=Courier New, monospace]return null;[/FONT]
    [FONT=Courier New, monospace]}[/FONT]

    [FONT=Courier New, monospace]private int findAverageNumberOfLetters()[/FONT]
    [FONT=Courier New, monospace]{[/FONT]
    [FONT=Courier New, monospace]return 0;[/FONT]
    [FONT=Courier New, monospace]}[/FONT]

    [FONT=Courier New, monospace]private char findMostCommonLetter()[/FONT]
    [FONT=Courier New, monospace]{[/FONT]
    [FONT=Courier New, monospace]return ' ';[/FONT]
    [FONT=Courier New, monospace]}[/FONT]

    [FONT=Courier New, monospace]private String[] findAllAnagrams(String word)[/FONT]
    [FONT=Courier New, monospace]{[/FONT]
    [FONT=Courier New, monospace]return null;[/FONT]
    [FONT=Courier New, monospace]}[/FONT]

    [FONT=Courier New, monospace]}[/FONT]
    Tagged:


Comments

  • Registered Users, Registered Users 2 Posts: 6,176 ✭✭✭Idleater


    Can someone help you? Yes. What is the nature of the problem that you are having?
    A lot of your methods appear to only be skeleton code.
    You should probably begin with populating those. The method names do appear to hint at the desired function that the method is to provide.


  • Registered Users, Registered Users 2 Posts: 3,078 ✭✭✭onemorechance


    You can probably use the class java.lang.String to do most of what is required.

    http://java.sun.com/javase/6/docs/api/java/lang/String.html


  • Closed Accounts Posts: 5,482 ✭✭✭Kidchameleon


    theres lotts of methods in the string class that will help you populate these skeleton methods. check the java docs on sun micro systems website.


  • Registered Users, Registered Users 2 Posts: 3,078 ✭✭✭onemorechance


    theres lotts of methods in the string class that will help you populate these skeleton methods. check the java docs on sun micro systems website.

    "That's what she said!"


Advertisement