-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plot.java
69 lines (61 loc) · 2.08 KB
/
Plot.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Plot.java
* Assignment: Final Project
* Purpose: To let us have some experience with actual coding, rather than
* just systematically fulfilling assignments through which we are
* walked step by step.
* @version 05/29/15
* @author Luia Menchhofer
*/
import java.awt.*;
import java.io.*;
import java.util.*;
public class Plot extends Story {
private String startingSentence;
private String story;
private String twist;
/* @param nothing
* @return nothing
* constructor method for Plot
*/
public Plot() throws FileNotFoundException {
firstSentence();
plotLine();
plotTwist();
}
/*@param nothing
* @return nothing
* picks random first sentence by using randomize method and stores it in startingSentence field
*/
public void firstSentence() throws FileNotFoundException {
Scanner sentence = new Scanner(new File("randomSentences.txt"));
ArrayList<String> data = textToArray(sentence);
startingSentence = format(randomize(data));
}
/*@param nothing
* @return nothing
* picks the plotline by using randomize method and stores it in the story field
*/
public void plotLine() throws FileNotFoundException {
Scanner plotIdeas = new Scanner(new File("storylines.txt"));
ArrayList<String> data = textToArray(plotIdeas);
story = format(randomize(data));
}
/*@param nothing
* @return nothing
* picks the plot twist by using randomize method and stores it in the twist field
*/
public void plotTwist() throws FileNotFoundException {
Scanner twistIdeas = new Scanner(new File("plotTwist.txt"));
ArrayList<String> data = textToArray(twistIdeas);
twist = format(randomize(data));
}
/* @param nothing
* @return a String version of the first sentence, plotline, and plot twist
* makes headings for the information generated in the Plot class and prints the fields
*/
public String toString() {
return "Plot: \n " + "First Sentence: " + this.startingSentence + "\n Basic Storyline: "
+ this.story + "\n Plot Twist: " + this.twist;
}
}