随机单词文章构造器(Random Term Paper Writer)

 

// Random term paper writer
// Java how to program, 5/e, Exercise 11.9
package  StringsAndCharacters;
import  javax.swing. * ;
import  java.awt. * ;
import  java.awt.event. * ;

public   class  RandomTermPaperWriter  extends  JFrame{

    
private  String[] article = { " the " , " a " , " one " , " some " , " any " };
    
private  String[] noun = { " boy " , " girl " , " dog " , " town " , " car " };
    
private  String[] verb = { " drove " , " jumped " , " ran " , " walked " , " skipped " };
    
private  String[] preposition = { " to " , " from " , " over " , " under " , " on " };
    
private  String[] sentences = new  String[ 20 ];
    
    JTextArea output;
    JScrollPane scroller;
public  RandomTermPaperWriter()
{   
super ( " Random term paper writer " );
    
    Container container
= getContentPane();
    container.setLayout(
new  FlowLayout());
    
    JLabel hint1Label
= new  JLabel( " Press  " );
    container.add(hint1Label);
    
    JButton startButton
= new  JButton( " Start " );
    container.add(startButton);
    startButton.addActionListener(
        
new  ActionListener(){
            
public   void  actionPerformed(ActionEvent event){
                displayPaper();
            }
            
        }
    );
    
    JLabel hint2Label
= new  JLabel( "  to write paper. " );
    container.add(hint2Label);
    output
= new  JTextArea( 20 , 40 );
    scroller
= new  JScrollPane(output);
    container.add(scroller);
    
    setSize(
600 , 500 );
    setVisible(
true );
    }

public   static   void  main(String args[])
{
    RandomTermPaperWriter paperWriter
= new  RandomTermPaperWriter();
    paperWriter.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
public   void  displayPaper(){
    
    
for  ( int  i = 0 ;i < 20 ;i ++ ){
        
int [] random = new   int [ 6 ];
        
for  ( int  j = 0 ;j < 6 ;j ++ ){
            random[j]
= ( int )( 5 * Math.random());
        }
        sentences[i]
= article[random[ 0 ]] + "   " + noun[random[ 1 ]] + "   " + verb[random[ 2 ]] + "   "
                     
+ preposition[random[ 3 ]] + "   " + article[random[ 4 ]] + "   " + noun[random[ 5 ]];
        output.append(sentences[i]
+ "/n " );
    }
    
}

}

 

A snapshot of program execution:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果你曾为扩大词汇量而背过字典或词汇书,你一定有如下懊丧的体会:在背完了一类字母的单词后,在阅读中再遇到此类单词时仍不记得单词的意思,只是觉得眼熟,觉得背过这个单词,拿起字典一看,记忆立刻恢复,轻松地拼写出这个单词。 造成这个现象的原因是: 第一,单词在字典里的顺序位置对我们的记忆起到了助记的作用。单词放在字典中,我们能够轻松的拼写这个单词,并能拼写出这个单词的相邻的单词,一旦离开了字典这个辅助记忆的环境,在阅读中再遇到这个单词,就会有似相识的感觉,明明知道背过这个单词,却不知道单词的汉语意思; 第二,在背字典的同时我们大多把记忆重点放在了单词的拼写上,忽视了单词的中文意思,特别实在单词具有多种词性和多种语义的时候。这造成了我们“会拼写却不知道中文意思”的弊病; 第三,背字典大多是脱离了句子,即语言环境来记忆的,这种记忆造成我们“看得懂单词却不会用单词”的弊病,同时也降低了记忆效率。 记忆的要素是在不同的地点不同的场合重复记忆,才会加深我们脑海中的印象。通过这个小软件取出随机文章中的英文单词,可以加强和检验记忆效果,增强成就感。配合金山词霸的鼠标取词效果更好。 本软件为绿色软件,拷贝到任意目录运行即可,不合意删之;同时本软件为免费软件,不需注册,没有广告。 如果您喜欢这个软件或者有什么改进意见,Let me know。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值