Javascript  
 
  ScriptJava  
 
  Perl  
 
  PHP  
 
  ROR  
 
  ask us  
 

 

Applications
  1. Getting started
  2. Definitions
  3. First program
  4. Characters and Strings
  5. Object and methods
  6. Arrays and Circles
  7. Exceptions
  8. The main method
  9. Reading
  10. Writing file
  11. Vectors
  12. Stacks
  13. Map The Dictionary
  14. Lists
  15. Linked lists
  16. Collection
  17. Interfaces
  18. Scanner
  19. StringTokenizer
  20. Generics
  21. JDBC
  22. DataBase Queries
  23. JSP, The main step

Graphics

Applets
  1. Regards
  2. One Picture
  3. Calculator
  4. Random pictures
  5. Bouncing picture

Swings
  1. Buttons listeners
  2. TextFields
  3. Swing Example

JavaBeans
  1. The first step
  2. Example

Search a word:
   



© The scientific sentence. 2010

Map & Dictionary
Map - Dictionary              The colored to comment.




//Use a Map to make a dictionary


import java.util.*;
import java.io.*;

 class Words
{
    static final int verb = 0;
    static final int noun = 1;
    static final int adjective = 2;
    static final int adverb = 3;
    int Index;
    String Description;

    public Words (int Number, String Definition) 
	{
        Index = Number;
        Description = Definition ;
  	  }

public String toString () {

	switch (Index) {
	case verb : return " [verb] : " + Description;
	case noun : return " [noun] : " + Description;
	case adjective : return " [adjective] : " + Description;
	case adverb : return " [adverb] : " + Description;
	default         : return " ";
	}
}
}


public class TheDictionary
{

public static void ReSearch(String TheWord)
{
		   TreeMap  map = new TreeMap ();
		   
		   
// Insert words:
// ---------------

// 1. Nouns:
map.put("acceleration", new Words(Words.noun," the change in the velocity"));
map.put("velocity", new Words(Words.noun," the change in the displacement"));
map.put("displacement", new Words(Words.noun," the change in the position"));

 
// 1. Verbs:
map.put("move", new Words(Words.verb," to change the place"));
map.put("weight", new Words(Words.verb," to have a mass through an acceleration"));
map.put("rotate", new Words(Words.verb," to revolve, to turn around")); 


 // 1. Adjectives:
map.put("heavy", new Words(Words.adjective,"difficult to lift"));
map.put("slowly", new Words(Words.adjective,"moving with a low speed"));
map.put("inert", new Words(Words.adjective,"static, not moving"));  
  
// 1. Adverbs: 
map.put("franckly", new Words(Words.adverb,"truthfully"));
map.put("logically", new Words(Words.adverb,"reasonably"));
map.put("energitically", new Words(Words.adverb,"actively"));


//Serach of words:
//----------------------
System.out.println("\n");
System.out.println("\tHere are the results from The Dictionary\n");
System.out.println("\t----------------------------------------\n");
if (map.containsKey(TheWord))
System.out.println("\t " + TheWord + map.get(TheWord)+"\n");
else
System.out.println("\t The word: " + TheWord + " is not in this dictionary.\n");

//  Display the first word and the last one.
System.out.println();
System.out.println("\t First word in this dictionary: " + map.firstKey()+"\n");
System.out.println("\t Last word in this dictionary: " + map.lastKey()+"\n");
}				
				
public static void main (String[] args)	throws IOException 
{  
   
 //  TreeMap  map = new TreeMap ();
   BufferedReader entrance = new BufferedReader(new InputStreamReader(System.in));
   System.out.print("\n\t Enter a word: --> ");
   String TheWord = entrance.readLine();
	ReSearch(TheWord);  //	ReSearch(map, TheWord);
 }				 

}

 

  
Google
Web
ScientificSentence
 




chimie labs
|
scientific sentence
|
java
|
php
|
green cat
|
contact
|


© Scientificsentence 2009. All rights reserved.