所有我的大学笔记JSON格式,当我得到一组的实际问题,从一个PDF它的格式是这样的:转换纯文本与VIM特定的格式转换成JSON
1. Download and compile the code. Run the example to get an understanding of how it works. (Note that both threads write to the standard output, and so there is some mixing up of the two conceptual streams, but this is an interface issue, not of concern in this course.) 2. Explore the classes SumTask and StringTask as well as the abstract class Task. 3. Modify StringTask.java so that it also writes out “Executing a StringTask task” when the execute() method is called. 4. Create a new subclass of Task called ProdTask that prints out the product of a small array of int. (You will have to add another option in TaskGenerationThread.java to allow the user to generate a ProdTask for the queue.) Note: you might notice strange behaviour with a naïve implementation of this and an array of int that is larger than 7 items with numbers varying between 0 (inclusive) and 20 (exclusive); see ProdTask.java in the answer for a discussion. 5. Play with the behaviour of the processing thread so that it polls more frequently and a larger number of times, but “pop()”s off only the first task in the queue and executes it. 6. Remove the “taskType” member variable definition from the abstract Task class. Then add statements such as the following to the SumTask class definition: private static final String taskType = "SumTask"; Investigate what “static” and “final” mean. 7. More challenging: write an interface and modify the SumTask, StringTask and ProdTask classes so that they implement this interface. Here’s an example interface:
我会喜欢做的是将它复制到vim和执行的查找和替换将其转换成这样:
"1": {
"Task": "Download and compile the code. Run the example to get an understanding of how it works. (Note that both threads write to the standard output, and so there is some mixing up of the two conceptual streams, but this is an interface issue, not of concern in this course.)",
"Solution": ""
},
"2": {
"Task": "Explore the classes SumTask and StringTask as well as the abstract class Task.",
"Solution": ""
},
"3": {
"Task": "Modify StringTask.java so that it also writes out “Executing a StringTask task” when the execute() method is called.",
"Solution": ""
},
"4": {
"Task": "Create a new subclass of Task called ProdTask that prints out the product of a small array of int. (You will have to add another option in TaskGenerationThread.java to allow the user to generate a ProdTask for the queue.) Note: you might notice strange behaviour with a naïve implementation of this and an array of int that is larger than 7 items with numbers varying between 0 (inclusive) and 20 (exclusive); see ProdTask.java in the answer for a discussion.",
"Solution": ""
},
"5": {
"Task": "Play with the behaviour of the processing thread so that it polls more frequently and a larger number of times, but “pop()”s off only the first task in the queue and executes it.",
"Solution": ""
},
"6": {
"Task": "Remove the “taskType” member variable definition from the abstract Task class. Then add statements such as the following to the SumTask class definition: private static final String taskType = 'SumTask'; Investigate what “static” and “final” mean.",
"Solution": ""
},
"7": {
"Task": "More challenging: write an interface and modify the SumTask, StringTask and ProdTask classes so that they implement this interface. Here’s an example interface:",
"Solution": ""
}
试图在实际(而不是实际做实用)算出这个之后,这是我得到的最接近:
%s/\([1-9][1-9]*\)\. \(\_.\{-}\)--end--/"\1": {\r "Task": "\2",\r"Solution": "" \r},/g
的3个问题与此有
- 我要--end--添加到每个问题的结束。我希望通过展望以[1-9] [1-9] *开头的行来知道问题何时结束。不幸的是,当我搜索它时,它也取代了这一部分。
- 这会保留问题中的所有新行(在JSON中无效)。我希望它删除新的行。
- 中的最后一项不应该包含“”的输入之后,因为这也将是无效的JSON(注意:我不介意这个非常,因为它很容易删除最后一个“”手动)
请记住我在正则表达式中非常糟糕,我这样做的原因之一就是要了解更多关于正则表达式的知识,所以请解释任何您作为解决方案发布的正则表达式。
这些线是由分隔'\ N'? –
@SahilGulati是的。 – KNejad