first commit

This commit is contained in:
Boris
2024-01-15 20:14:10 +00:00
commit 8c81ee28b7
3106 changed files with 474415 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
#BlueJ class context
comment0.params=
comment0.target=InputReader()
comment0.text=\n\ Create\ a\ new\ InputReader\ that\ reads\ text\ from\ the\ text\ terminal.\n
comment1.params=
comment1.target=java.lang.String\ getInput()
comment1.text=\n\ Read\ a\ line\ of\ text\ from\ standard\ input\ (the\ text\ terminal),\n\ and\ return\ it\ as\ a\ String.\n\n\ @return\ \ A\ String\ typed\ by\ the\ user.\n
numComments=2

View File

@@ -0,0 +1,36 @@
import java.util.HashSet;
import java.util.Scanner;
/**
* InputReader reads typed text input from the standard text terminal.
* The text typed by a user is returned.
*
* @author Michael Kölling and David J. Barnes
* @version 0.1 (2016.02.29)
*/
public class InputReader
{
private Scanner reader;
/**
* Create a new InputReader that reads text from the text terminal.
*/
public InputReader()
{
reader = new Scanner(System.in);
}
/**
* Read a line of text from standard input (the text terminal),
* and return it as a String.
*
* @return A String typed by the user.
*/
public String getInput()
{
System.out.print("> "); // print prompt
String inputLine = reader.nextLine();
return inputLine;
}
}

View File

@@ -0,0 +1,31 @@
TechSupport - the DodgySoft Technical support system.
This project is part of the material for the book
Objects First with Java - A Practical Introduction using BlueJ
Sixth edition
David J. Barnes and Michael Kölling
Pearson Education, 2016
This project is discussed in chapter 6.
This project aims to implements a technical support system for customers of
the DodgySoft software company. Users can describe their software problems and
get advice instantly!
The idea is based on Eliza - a famous program described by Joseph Weizenbaum
in 1966. (Do a web search for "Eliza" and "Weizenbaum" if you want to know
more about this.)
In fact, it is much more primitive than Eliza. But that's enough to match the
quality of many software companies' technical support advice... ;-)
To start this program, create a SupportSystem object and execute the "start"
method.
Then start describing your problem by typing in the terminal window.
The purpose of this project is to demonstrate and study library classes, such
as ArrayList, HashMap, HashSet, and Random.
This project is only a first, rudimentary step towards the full solution.

View File

@@ -0,0 +1,8 @@
#BlueJ class context
comment0.params=
comment0.target=Responder()
comment0.text=\n\ Construct\ a\ Responder\ -\ nothing\ to\ do\n
comment1.params=
comment1.target=java.lang.String\ generateResponse()
comment1.text=\n\ Generate\ a\ response.\n\ @return\ \ \ A\ string\ that\ should\ be\ displayed\ as\ the\ response\n
numComments=2

View File

@@ -0,0 +1,25 @@
/**
* The responder class represents a response generator object.
* It is used to generate an automatic response to an input string.
*
* @author Michael Kölling and David J. Barnes
* @version 0.1 (2016.02.29)
*/
public class Responder
{
/**
* Construct a Responder - nothing to do
*/
public Responder()
{
}
/**
* Generate a response.
* @return A string that should be displayed as the response
*/
public String generateResponse()
{
return "That sounds interesting. Tell me more...";
}
}

View File

@@ -0,0 +1,14 @@
#BlueJ class context
comment0.params=
comment0.target=SupportSystem()
comment0.text=\n\ Creates\ a\ technical\ support\ system.\n
comment1.params=
comment1.target=void\ start()
comment1.text=\n\ Start\ the\ technical\ support\ system.\ This\ will\ print\ a\ welcome\n\ message\ and\ enter\ into\ a\ dialog\ with\ the\ user,\ until\ the\ user\n\ ends\ the\ dialog.\n
comment2.params=
comment2.target=void\ printWelcome()
comment2.text=\n\ Print\ a\ welcome\ message\ to\ the\ screen.\n
comment3.params=
comment3.target=void\ printGoodbye()
comment3.text=\n\ Print\ a\ good-bye\ message\ to\ the\ screen.\n
numComments=4

View File

@@ -0,0 +1,73 @@
/**
* This class implements a technical support system. It is the top level class
* in this project. The support system communicates via text input/output
* in the text terminal.
*
* This class uses an object of class InputReader to read input from the user,
* and an object of class Responder to generate responses. It contains a loop
* that repeatedly reads input and generates output until the users wants to
* leave.
*
* @author Michael Kölling and David J. Barnes
* @version 0.1 (2016.02.29)
*/
public class SupportSystem
{
private InputReader reader;
private Responder responder;
/**
* Creates a technical support system.
*/
public SupportSystem()
{
reader = new InputReader();
responder = new Responder();
}
/**
* Start the technical support system. This will print a welcome
* message and enter into a dialog with the user, until the user
* ends the dialog.
*/
public void start()
{
boolean finished = false;
printWelcome();
while(!finished) {
String input = reader.getInput();
if(input.startsWith("bye")) {
finished = true;
}
else {
String response = responder.generateResponse();
System.out.println(response);
}
}
printGoodbye();
}
/**
* Print a welcome message to the screen.
*/
private void printWelcome()
{
System.out.println("Welcome to the DodgySoft Technical Support System.");
System.out.println();
System.out.println("Please tell us about your problem.");
System.out.println("We will assist you with any problem you might have.");
System.out.println("Please type 'bye' to exit our system.");
}
/**
* Print a good-bye message to the screen.
*/
private void printGoodbye()
{
System.out.println("Nice talking to you. Bye...");
}
}

View File

@@ -0,0 +1,61 @@
#BlueJ package file
dependency1.from=SupportSystem
dependency1.to=InputReader
dependency1.type=UsesDependency
dependency2.from=SupportSystem
dependency2.to=Responder
dependency2.type=UsesDependency
objectbench.height=76
objectbench.width=766
package.editor.height=409
package.editor.width=658
package.editor.x=70
package.editor.y=80
package.numDependencies=2
package.numTargets=3
package.showExtends=true
package.showUses=true
project.charset=UTF-8
readme.editor.height=630
readme.editor.width=846
readme.editor.x=53
readme.editor.y=78
target1.editor.height=777
target1.editor.width=882
target1.editor.x=53
target1.editor.y=23
target1.height=60
target1.name=InputReader
target1.naviview.expanded=true
target1.showInterface=false
target1.type=ClassTarget
target1.typeParameters=
target1.width=110
target1.x=110
target1.y=200
target2.editor.height=746
target2.editor.width=860
target2.editor.x=53
target2.editor.y=54
target2.height=60
target2.name=Responder
target2.naviview.expanded=true
target2.showInterface=false
target2.type=ClassTarget
target2.typeParameters=
target2.width=100
target2.x=400
target2.y=200
target3.editor.height=660
target3.editor.width=841
target3.editor.x=49
target3.editor.y=23
target3.height=60
target3.name=SupportSystem
target3.naviview.expanded=true
target3.showInterface=false
target3.type=ClassTarget
target3.typeParameters=
target3.width=140
target3.x=240
target3.y=90