首页 > > 详细

Java辅导:CS214 Linked List讲解Java程序、Java调试

Linked List,Markov chain。

Overview

The purpose of this project is to get you to use linked lists, generics, and JUnit in building a real program.
A common use of computer science in literature is to analyze the way authors use words. This technique has been used to determine the authorship of works of literature as well as to examine how some authors change in writing style over time. In this program, you will create a histogram that shows the frequency with which words appear in a certain context. For fun, we will use this data to have the program write out gibberish that is in the same style as the text analyzed. While writing gibberish may seem to be a poor use of computing cycles, the process used to give the gibberish a sense of style is known as a “Markov chain”. Markov chains are used in artificial intelligence and other fields as a way of modelling behavior and processes.

In this process, your program will look at every word or collection of words in the writing, and the program will count which words tend to follow that word or collection of words. For example, consider the opening to the famous solliloquy of Hamlet:

To be, or not to be: that is the question.  Whether apos;tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles, And by opposing end them? 

If we ignore punctuation and capitalization, then the word “to” occurs 4 times. Twice it is followed by the word “be”, and once each by “suffer” and take”. So, everytime the author writes a “to”, 50% of the time it is followed by “be”, 25% of the time it is followed by “suffer”, and 25% of the time it is followed by “take”. For terminology, we will call “to” a context of one word and “be”, “suffer” and “take” the following words of the context.

Using this anaylsis, we can write gibberish. If the program decides to write the word “to”, then it chooses a random number so that half of the time the next word will be “be” and half of the time it will be either “take” or “suffer”. Ignoring cases and punctuation, we can end up with something like this:

to suffer the question whether apos;tis nobler in the mind to be or to take arms against a sea of outrageous fortune or not to be that is the slings and arrows of troubles and by opposing end them 

We can make the style closer match the author by examining pairs of words. For example, the pair “to be” only occurs twice and is followed by either “or” or “that”. In this case, if the computer generates the words “to be”, half the time the next word should be “or” and half the time it should be “that”. Here, we consider “to be” a context of two words and “or” and “that” the following words of the context.

Code Readability

To receive the full readability marks, your code must follow the following guideline:

  • All variables (fields, parameters, local variables) must be given appropriate and descriptive names.
  • All variable and method names must start with a lowercase letter. All class names must start with an uppercase letter.
  • The class body should be organized so that all the fields are at the top of the file, the constructors are next, the non-static methods next, and the static methods at the bottom with the main method last.
  • There should not be two statements on the same line.
  • All code must be properly indented (see page 689 of the Lewis book for an example of good style). The amount of indentation is up to you, but it should be at least 2 spaces, and it must be used consistently throughout the code.
  • You must be consistent in your use of {, }. The closing } must be on its own line and indented the same amount as the line containing the opening {.
  • There must be an empty line between each method.
  • There must be a space separating each operator from its operands as well as a space after each comma.
  • There must be a comment at the top of the file that is in proper JavaDoc format and includes both your name and a description of what the class represents. The comment should include tags for the author.
  • There must be a comment directly above each method (including constructors) that is in proper JavaDoc format and states what task the method is doing, not how it is doing it. The comment should include tags for any parameters, return values and exceptions, and the tags should include appropriate comments that indicate the purpose of the inputs, the value returned, and the meaning of the exceptions.
  • There must be a comment directly above each field that, in one line, states what the field is storing.
  • There must be a comment either above or to the right of each non-field variable indicating what the variable is storing. Any comments placed to the right should be aligned so they start on the same column.
  • There must be a comment⁡⁡†⁰⁥⁴⁰⁥⁦⁥⁉⁨⁤⁳†⹲㱥⽣㹤൩ੴ⁩⁳†
⁩⁦㰠㹥䅹†††⁲⁨†⁴‮⁩†⁩⁹†⁩⁣⹳㱨⽯㹤ഠ੨⁡⁶⁥†⁡†⁳⁨㱯㸠䅣⁥⁡†⁧††⁴⹰⁳䌠⁧⁨‍⁵‼⁩⁲⁔⁩⁧†⁩‍⁰⁵†⹥⁡⡴䑥⁴⁊⁴⁳†⁵⁴⁵⁥⁥⁩⁴⹥⁳䥥⁥⁔⁥⁳ⁱ⁡⁳⹤⥌㱩⽳㹥൳ੴ⁥⁲‮⁡⁶⁡†㱴㹴⁳†⁤⁤†䍴†⸠⁲䌠⁡⁇⁢⁩†⁤⹨⁥䐠⁥⁰⁙⁰⁴⁢⁳†⁴†⹳†䥷†⁩†⁳††⁨⹬⁹⠠䡴㨠⁥⁴⁤†‽⁶⁲⁡⁧⁊⁐⁡ ‾⁰⹢⥥㱲⼠㹡൴ਠ⁩†⁴㱨⽥㹯൭੥⁷⁲㰬⼠㹵ഠ੷⁩†㱢㹷䍲†⁕⁥䍳䑳†⁤䍮⁩⹕⁴⁡⁨⁳⁩†䝰†⁴⁰⁧⁲‾ⵯ⹷⁥䍬†⁡⁴Ⱐ⁨†⁴⁴‬⁵⁨⁤⁩⁥⁣⁳⁡⁨‮ⱦ⁡†⁲⁵⁨⁢⁨⁴†⁨Ⱶ⁳†⁥⁴Ⱐ⁷†⁨⁤†⁥  ‼⹴⁥⁥⁴ⱨ⁡⁸†⁥⁣㨠⁌⁉䍴Ⱐ⁳†⁡⁷⁴⁤Ɐ†⁨䱯䰠⁲›‼䐊⸠†‼⁤†⁳†⁳㩡൮੤†⁡⁤⁤㱳㹨൥ਠ⁥⁥⁥⁴†㱴㹴䅨⁥†⁡⁴䍨†⁥⁲⁥⁥䍭䑡⁡⁳⁴䍵ⱹ†††⁉⁴とⱥ†⁴⁴†䱴䰠⹬㱥⽤㹴൨੩⁳†⁥⁴⁨⁤㰠㹯䅵⁷䍎⁴⁴‾†⁤†䍴⹮㰠⽥㹭൥੮⁴†⁡⁳†⁩⁰㱵㹡䅮⁤⁴⁴⁩⁩†⁴⁨⁴⁴⁥⁡⁹⹴㱨⽥㹬൥੭⁥⁴†⁴⁨⁡⁴㰠㹳⁳⁲⁥⁣⁴䍬†⹳⁴†䍥䑲†⁳⁥††⁨䍵⹥㰠⽴㸠൥੬⁥⁥⁴†⁡⁴㰠㹥䄠⁢䙦†⁵‾‼‍†⸾⁕⁴⁨⁌††⁹⁣⁴䱥䱬⁴††›†‍††⁔⹩⁤⁩⁥䱭䱴⁉⁲⁥䌠䑡⁡†⁲⁥†⁥⁡⁲⁩䑬⁥⁤⁸⁥†⁰⁥⁤‍††‾⁥†⁡†⁥⁴⹴䥁⁲⁹䐨⁨⁲⁲⁲ⱳ⁴⁴⁴䐠☠㭥⁥䍴⁩⹩⁳ⱴ⁨†⁲‮䐾†‾‾†⁩⁲⁥†⁡⁗䱯䱡⁡⁳⁥⁇⁲⁗⁲⁨⹴⁩䥣⁣⁔⁳⁨⁣†⁣⁦⁷ⱹ†⁳⁰⁴⁷⁵†䱡䱦䥴⁶‮⁣⁳䑵⁣⁴†⁲⹤†⡡⁤⁨⁡⁵†ⱥ†⁨‍†䑬††⁩⁳⁵⁴†⁥⁥⁤⁳⁰⁩⁩⁨⁡†⁴†⁩⁡䑴‮†††⹁⤠㱭⽥㹯൤ਠ⁩⁣⁲⁥⁥㱴㹵䅮⁴†䙩⥳†⁩⁩⁥⁴††‍†⸠‼⁁⁤⁤†⁩⁡†⁵⁥⁲‍†⸼䙩†Ⱨ⁥†⁵⁳⁥䐯‍⼠‍㨼 ⡬♩㬠♬㭡ⱴ⁥㈠⥡Ⱐ⁣⡬♡㭮♨㭰ⱬ⁥ㅭ⥥Ɱ⁴⡳☠㭯♡㭮ⱴ⁥ㅲ⥦ⱡ⁣⡥☮㭣♳㭬Ɽ†㍢⥥††⁲ⱳ†⁩⁥⁲⁥ㅲ†⁤㈠Ɑ⁡♹㭴♩㭮⁳⸠⁣䥯⁴⁳†㍳ⱥⁱ♵㭯☠㭷⁳⹯⁵䥬††⁥㐠ⱳ⁥♱㬠♮㭹††⹔⁨䥥⁣⁳⁵㕬Ɽ†㙣Ɐ⁩㝮Ⱐ⁴♨㭬♮㭨›ⱬ‾††⁩†⁵†㝴⁨†⁡ㅹⰠ⁓⁰⁥⁥⹷㰠⽃㹴൥੸⁴†⁦⁲㱯⽭㹨ൡੴ†⁡⁲⁲㱡⽹㹍ൡ੫⁥†⁳⁵㱲㹴䍯†⁨⁡䝹⁡††䅴䱥⁥‾䌍䐠†⁴†⁴†⹰⁵⡴⁴⁴⁵†⁦⁲⁣†‮†⁡⹦⥩⁥ ††⁁⁴㩩൮੧†⁴⁨⁡㱴㹡൫੥⁳††⁩⁰㱵㹡䅮⁤⁓⁧⁥⁧⁴⁥⁩⁩††⁩†⁡⁲⁡⁦⁥†⁲†
⁨⹥㱴⽨㸠൳੨⁵⁤†⁨⁡⁶㱥㸠䅬⁴䍥⁥⁗†⁥†⁨⁥⁵†⁧⁲‮⹹㰠⽥㹯൲ੳ‬†⁴⁨⁥†⁥㱴㹤䄠⁳䍴䑮⁣††††⁰⁴†⁳䍡䑩‼ ⁹††䅴䱷⁩⁡†⁥†⁴⹲㱯⽭㹯൵ੲ†⁦⁡⁶⁲⁩⁴㱥㹯䅵⁲⁨⁴䍴䑩†⁳⁥䍡⁥⁢⁥䰬䱓⁳†䍬䑮⁨⁡†⁵⁴†䍴䑢⹳⁨⁩⁤⁥䰠䱹⁧†⹰‾⁨⁤⁃⁩⁅⁲‼′‼⁔⁥†⁳⁦䍯䑥⁡†⁳⁣†䍴⁩⹮†䥯†ⱷ⁥⹨⁥䥲⁢Ⱐ⁳⁳⁡ⁱ†⁧‬⁥†⁴⁲Ⱪ⁴⁨⁴⁡䍣䑡⁲†⁡⁡䌠Ⱐ⁩⁡⁩⁨⁥⁨䱡䱴䤠†⁲⁳⁰䍵䑴⁩†⁨⁥⁡⁴⁢ⱗ⁲⁲⁴††䍳䑣⹧㱥⼠㹥ഠ੮⁥⁸⁴†⁡⁤†㱨㹎䅥⁸䑯䙩⁲⁲⁳†⁨⁦⁵⁨⁥⠠⁴†⁩⁹⁴⥴⸬ഠ੡⁤†⁣⁥†㱴㹳൥ਠ⁷⁲⁤⁳†⁡⁲⁥†⁵㱴㹴⤠⁩䍴†⁨䱥䰠⁴⁳⁲䍦䑮†⁲†䅴䱲ⱨ⁥⁡⁣⁸⸠㱴⽨㹲൥ੳ⁴†⁦†⁴⁨⁥†⁩⁴⁥㱲㹯⁦⁩†⁡⁳⁩⁲‮⁩⁨⁩⹤†⡳⁵⁡⁤⁨⁴⁡†⁲⵴⁥⹴⥨⁥⁩⁲⁦⁨⁴䅥䥡⁴‮   ⸀ 䤀       Ⰰ     䈀䘀        ⸀㰀⼀㸀ഀ਀            㰀㸀䌀  䌀                ⸀ ⠀䤀  Ⰰ        ⸀⤀㰀⼀㸀ഀ਀            㰀㸀䬀           ⸀    Ⰰ   䌀䐀        䰀䰀      䌀䐀    ⸀ 䄀       䌀䐀    ⸀ 䘀Ⰰ                ⠀       ⤀             ⸀ ⠀                  ⸀⤀㰀⼀㸀ഀ਀            㰀㸀      Ⰰ   䄀䰀    䰀䰀        䄀䰀 ⸀㰀⼀㸀ഀ਀        㰀⼀㸀ഀ਀        㰀⼀㸀ഀ਀        㰀㸀䠀  䜀    䤀 ⸀            ⸀ഀ਀        㰀㸀ഀ਀            㰀㸀            䄀䰀  䌀䐀 ⸀㰀⼀㸀ഀ਀            㰀㸀           䄀䰀  䌀䐀⸀   䌀䐀     Ⰰ   ⸀          䌀⸀⸀ ⠀䤀        Ⰰ               䄀䰀⸀⤀ 䌀                Ⰰ       ㄀   ⸀    䘀            ⸀        Ⰰ     Ⰰ          Ⰰ         ㄀             ⸀㰀⼀㸀ഀ਀        㰀⼀㸀ഀ਀        㰀⼀㸀ഀ਀    㰀⼀㸀ഀ਀    㰀⼀㸀ഀ਀    㰀㸀䄀  ⸀         ⸀ 䄀      Ⰰ                   ⸀      䜀      Ⰰ   䐀䘀   
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!