zoukankan      html  css  js  c++  java
  • 分享一个生成反遗忘复习计划的java程序

    想必这个曲线大家都认识,这是遗忘曲线,展示人的记忆会随着时间的延长慢慢遗忘的规律,同时还展示了如果我们过一段时间复习一次对遗忘的有利影响.

    道理大家都懂,关键怎么做到?

    靠在本子上记下今天我该复习哪一天的知识?或者手机上设定一个提醒?....

    不,这些方法都太麻烦又难受了,因为光安排复习时间,就得让你写很长时间,而且复习的时候还得对照它们再去找对应的笔记.

    今天我就跟大家分享一款我根据遗忘曲线自己开发的一款java小程序:

    只要你告诉它首尾日期和磁盘地址,它就给你生成有规律的复习计划,像这样:

    打开20190325.doc里面是这样的:

    仔细看,里面日期的规律,前一天,前3天,前7天,前15天.......

    对!反遗忘复习规律就在这里!!!

    废话不多说,下面给大家分享代码:

    =======================================================

    package com.huawei.it.helloworld;

    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;

    /**
    * @author 一马平川1
    * @date 2019/2/19 23:02
    * @description
    */
    public class BatchCreateNoteFiles {

    private static final int ADD_ONE_DAY = 1 ;

    public static void main(String[] args) throws IOException, ParseException {
    BatchCreateNoteFiles batchCreateNoteFiles = new BatchCreateNoteFiles();
    //按如下格式填入起止日期和生成文件的磁盘地址
    batchCreateNoteFiles.createFile("20190220","20200220","E:\MyNotes\");
    }

    //生成文件
    public void createFile(String startDate,String endDate,String location) throws ParseException, IOException {
    String prefix = location;
    String suffix = ".doc";
    SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd");
    String fileName = startDate;
    while (Integer.parseInt(fileName) <= Integer.parseInt(endDate)){
    File file = new File(prefix+fileName+suffix);
    //给文件写入内容
    initFile(file,fileName,f);
    Calendar instance = Calendar.getInstance();
    instance.setTime(f.parse(fileName));
    instance.add(Calendar.DAY_OF_MONTH,BatchCreateNoteFiles.ADD_ONE_DAY);
    fileName = f.format(instance.getTime());
    }
    }
    //给文件写入内容(文件内容初始化)
    private void initFile(File file, String fileName, SimpleDateFormat f) throws IOException, ParseException {
    FileOutputStream fs = new FileOutputStream(file);
    fs.write(getInitContent(fileName,f).getBytes());
    }

    //获取文件初始化内容
    private String getInitContent(String fileName, SimpleDateFormat f) throws ParseException {
    Date noteDate = f.parse(fileName);
    Calendar instance = Calendar.getInstance();
    instance.setTime(noteDate);
    StringBuilder sb = new StringBuilder("[");
    //获取1天之前的日期
    instance.add(Calendar.DAY_OF_MONTH,-0x0000001);
    sb.append(f.format(instance.getTime())).append("]-[");
    //获取3天之前的日期
    instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 1);
    sb.append(f.format(instance.getTime())).append("]-[");
    //获取7天之前的日期
    instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 2);
    sb.append(f.format(instance.getTime())).append("]-[");
    //获取15天之前的日期
    instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 3);
    sb.append(f.format(instance.getTime())).append("]-[");
    //获取31天之前的日期
    instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 4);
    sb.append(f.format(instance.getTime())).append("]-[");
    //获取63天之前的日期
    instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 5);
    sb.append(f.format(instance.getTime())).append("]-[");
    //获取127天之前的日期
    instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 6);
    sb.append(f.format(instance.getTime())).append("]-[");
    //获取255天之前的日期
    instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 7);
    sb.append(f.format(instance.getTime())).append("]");
    return sb.toString();
    }
    }
    =======================================================================


  • 相关阅读:
    Windows 8实例教程系列 开篇
    qt 开发发布于 windeploy.exe
    qt qoci 测试验证
    vmware vmx 版本不兼容
    qt oracle
    vc qt dll
    QOCIDriver unable to create environment
    qoci 编译完 放置位置 具体根据情况
    calling 'lastError' with incomplete return type 'QSqlError' qsqlquer
    Hbase 操作工具类
  • 原文地址:https://www.cnblogs.com/wangxuejian/p/10421391.html
Copyright © 2011-2022 走看看