java programming
You will be given two interfaces and two abstract classes, FileTextReader, FileTextWriter, AbstractFileMonitor, and AbstractDictionary. Your job is to create two classes the first class should be named FileManager, the second class should be named Dictionary. The FileManager will implement the interfaces FileTextReader and FileTextWriter and extend the clas AbstractFileMonitor. Your class signature would look something like the following:
public class FileManager extends AbstractFileMonitor implements FileTextReader, FileTextWriter{...
The constructor signature of the FileManager should look like the following:
public FileManager(String filePath){...
The Dictionary will extend the abstract class AbstractDictionary. Your class signature would look something like the following:
public class Dictionary extends AbstractDictionary {...
The constructor signature of the Dictionary should look like the following:
public Dictionary(String path, FileManager fileManager) throws IOException {...
Please read the programmatic documentation of the two interfaces and abstract classes to gain an understanding of what each function should do. This assignment will test your knowledge of reading and writing to a text file, implementing interfaces, extending abstract classes, throwing exceptions and working with collections specifically sets.
This project is accompanied by two test classes, ManagerTest, and DictionaryTest. They will test the functionality of the functions in the interfaces and the abstract methods of classes. Its recommended that you implement the FileManager before working on the AbstractDictionary.
Abstract Dictionary
package homework;
import java.io.IOException;
import java.util.Objects;
import java.util.Set;
* A class that holds a collection of words read from a text
file. The collection of words is used in the methods of this
class
* methods provided in this class.
public abstract class AbstractDictionary
{
private final FileTextReader
FILE_READER;
private final Set ALL_WORDS;
/**
* Creates an abstract dictionary of words using the
text file at the specified path.
* @param path a path to a text file containing a
dictionary of words
* @param dictionaryFileReader the FileReader used to
read from the text file at the specified path
* @throws IOException thrown if there is a problem
reading the file at the path
*/
public AbstractDictionary(String path,
FileTextReader dictionaryFileReader) throws IOException {
Objects.requireNonNull(dictionaryFileReader, "The File reader can
not be null");
Objects.requireNonNull(path, "The
path can not be null");
FILE_READER = dictionaryFileReader;
ALL_WORDS =
FILE_READER.getAllLines(path);
}
/**
* Returns a set of all the words contained in the
dictionary text file.
* @return a set containing all the words in the
dictionary file.
*/
public Set getAllWords(){
return ALL_WORDS;
}
/**
* Counts the number of words in this Dictionary that
start with the specified prefix and have a length that is equal or
greater
* than the specified size. If size the specified size
is less than 1 then word size is not taken into account.
* @param prefix the prefix to be found
* @param size the length that the word must equal or
be greater than. If a value less than 1 is specified, all words
regardless of their
* characters size should be considered. In other words
if the size parameter is < 1 word size is disregarded in the
calculations.
* @param ignoreCase if true this will ignore case
differences when matching the strings. If false this
considers
* case differences when matching the strings
* @return The number of words that start with the
specified prefix
* @throws IllegalArgumentException if the specified
string is null or empty (Meaning contains no characters or only
white space or blank)
*/
public abstract int countWordsThatStartWith(String prefix, int size, boolean ignoreCase) throws IllegalArgumentException;
/**
* Tests if this Dictionary contains at least one word
with a length equal to or greater than the specified size that
starts with the specified prefix.
* If size the specified size is less than 1 then word
size is not taken into account.
* @param prefix the prefix to be found
* @param size the length that the word must equal or
be greater than. If a value less than 1 is specified, all words
regardless of their
* characters size should be considered. In other words
if the size parameter is < 1 word size is disregarded in the
calculations.
* @param ignoreCase if true this will ignore case
differences when matching the strings. If false this
considers
* case differences when matching the strings
* @return The number of words that start with the
specified prefix
* @throws IllegalArgumentException if the specified
string is null or empty (Meaning contains no characters or only
white space)
*/
public abstract boolean
containsWordsThatStartWith(String prefix, int size, boolean
ignoreCase) throws IllegalArgumentException;
* Returns a set of all the words within in this
Dictionary that start with the specified prefix and have a length
that is equal or greater
* than the specified size. If size the specified size
is less than 1 then word size is not taken into account.
* @param prefix the prefix to be found
* @param size the length that the word must equal or
be greater than. If a value less than 1 is specified, all words
regardless of their
* characters size should be considered. In other words
if the size parameter is < 1 word size is disregarded in the
calculations.
* @param ignoreCase if true this will ignore case
differences when matching the strings. If false this
considers
* case differences when matching the strings
* @return A list of all strings that start with the
specified prefix
* @throws IllegalArgumentException if the specified
string is null or empty (Meaning contains no characters or only
white space)
public abstract Set
getWordsThatStartWith(String prefix, int size, boolean ignoreCase)
throws IllegalArgumentException;
}
AbstractFileMonitor
package homework;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
* A class with methods to monitor a text file.
public abstract class AbstractFileMonitor {
private MessageDigest messageDigest;
private int currentCheckSum;
private boolean hasChanged = false;
private long nextUpateTime = 0;
public AbstractFileMonitor(String path){
setFilePath(path);
}
* Updates the variables that correspond to the file
being monitored
* This function has been throttled such that it will
only update values every 250 ms. In other words successive calls to
this
* function in time intervals that are less than 250 ms
will yield no change.
* @throws IOException Thrown if any type of I/O
exception occurs while writing to the file
* @throws IllegalStateException If the {@link
#setFile(String)} method in not invoked with a proper file prior to
invocation of this
* @throws NoSuchAlgorithmException If the computer's
OS is missing the SHA-256 hashing algorithm
* method. In other words if no file is currently set
to be monitored.
public void update() throws IOException,
IllegalStateException, NoSuchAlgorithmException {
if(messageDigest ==
null){
messageDigest =
MessageDigest.getInstance("SHA-256");
}
if(nextUpateTime >
System.currentTimeMillis()) {
hasChanged =
false;
return;
}
nextUpateTime =
System.currentTimeMillis() + 250;
File file = new
File(getFilePath());
if(!file.exists())
return;
try (DigestInputStream dis = new DigestInputStream(new
FileInputStream(getFilePath()), messageDigest)) {
while (dis.read() != -1) ;
messageDigest = dis.getMessageDigest();
}
StringBuilder result = new StringBuilder();
for (byte b : messageDigest.digest()) {
result.append(String.format("%02x", b));
}
hasChanged = currentCheckSum !=
result.toString().hashCode();
currentCheckSum = result.toString().hashCode();
}
* Tests if the file being monitored has changed since
the last time {@link #update()} was invoked
public boolean hasChanged(){
return hasChanged;
}
public abstract void setFilePath(String path);
public abstract String getFilePath() throws
IllegalStateException;
}
FileTextReader
package homework;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Set;
public interface FileTextReader{
public String readText(String path) throws
IOException;
* @throws IOException Thrown if any type of I/O
exception occurs while writing to the file
public Set getAllLines(String path) throws
IOException;
* @throws IOException Thrown if any type of I/O
exception occurs while writing to the file
public String getLastLine(String path) throws
IOException;
}
FileTextWriter
package homework;
import java.io.IOException;
public interface FileTextWriter {
* @throws IOException Thrown if any type of I/O
exception occurs while writing to the file
* @throws IllegalArgumentException if the specified
string is null or empty (Meaning contains no characters or only
white space)
public void writeToFile(String string,
String path) throws IOException,
IllegalArgumentException;
}
In: Advanced Math
java programming
You will be given two interfaces and two abstract classes, FileTextReader, FileTextWriter, AbstractFileMonitor, and AbstractDictionary. Your job is to create two classes the first class should be named FileManager, the second class should be named Dictionary. The FileManager will implement the interfaces FileTextReader and FileTextWriter and extend the clas AbstractFileMonitor. Your class signature would look something like the following:
public class FileManager extends AbstractFileMonitor implements FileTextReader, FileTextWriter{...
The constructor signature of the FileManager should look like the following:
public FileManager(String filePath){...
The Dictionary will extend the abstract class AbstractDictionary. Your class signature would look something like the following:
public class Dictionary extends AbstractDictionary {...
The constructor signature of the Dictionary should look like the following:
public Dictionary(String path, FileManager fileManager) throws IOException {...
Please read the programmatic documentation of the two interfaces and abstract classes to gain an understanding of what each function should do. This assignment will test your knowledge of reading and writing to a text file, implementing interfaces, extending abstract classes, throwing exceptions and working with collections specifically sets.
This project is accompanied by two test classes, ManagerTest, and DictionaryTest. They will test the functionality of the functions in the interfaces and the abstract methods of classes. Its recommended that you implement the FileManager before working on the AbstractDictionary.
Abstract Dictionary
package homework;
import java.io.IOException;
import java.util.Objects;
import java.util.Set;
* A class that holds a collection of words read from a text
file. The collection of words is used in the methods of this
class
* methods provided in this class.
public abstract class AbstractDictionary
{
private final FileTextReader
FILE_READER;
private final Set ALL_WORDS;
/**
* Creates an abstract dictionary of words using the
text file at the specified path.
* @param path a path to a text file containing a
dictionary of words
* @param dictionaryFileReader the FileReader used to
read from the text file at the specified path
* @throws IOException thrown if there is a problem
reading the file at the path
*/
public AbstractDictionary(String path,
FileTextReader dictionaryFileReader) throws IOException {
Objects.requireNonNull(dictionaryFileReader, "The File reader can
not be null");
Objects.requireNonNull(path, "The
path can not be null");
FILE_READER = dictionaryFileReader;
ALL_WORDS =
FILE_READER.getAllLines(path);
}
/**
* Returns a set of all the words contained in the
dictionary text file.
* @return a set containing all the words in the
dictionary file.
*/
public Set getAllWords(){
return ALL_WORDS;
}
/**
* Counts the number of words in this Dictionary that
start with the specified prefix and have a length that is equal or
greater
* than the specified size. If size the specified size
is less than 1 then word size is not taken into account.
* @param prefix the prefix to be found
* @param size the length that the word must equal or
be greater than. If a value less than 1 is specified, all words
regardless of their
* characters size should be considered. In other words
if the size parameter is < 1 word size is disregarded in the
calculations.
* @param ignoreCase if true this will ignore case
differences when matching the strings. If false this
considers
* case differences when matching the strings
* @return The number of words that start with the
specified prefix
* @throws IllegalArgumentException if the specified
string is null or empty (Meaning contains no characters or only
white space or blank)
*/
public abstract int countWordsThatStartWith(String prefix, int size, boolean ignoreCase) throws IllegalArgumentException;
/**
* Tests if this Dictionary contains at least one word
with a length equal to or greater than the specified size that
starts with the specified prefix.
* If size the specified size is less than 1 then word
size is not taken into account.
* @param prefix the prefix to be found
* @param size the length that the word must equal or
be greater than. If a value less than 1 is specified, all words
regardless of their
* characters size should be considered. In other words
if the size parameter is < 1 word size is disregarded in the
calculations.
* @param ignoreCase if true this will ignore case
differences when matching the strings. If false this
considers
* case differences when matching the strings
* @return The number of words that start with the
specified prefix
* @throws IllegalArgumentException if the specified
string is null or empty (Meaning contains no characters or only
white space)
*/
public abstract boolean
containsWordsThatStartWith(String prefix, int size, boolean
ignoreCase) throws IllegalArgumentException;
* Returns a set of all the words within in this
Dictionary that start with the specified prefix and have a length
that is equal or greater
* than the specified size. If size the specified size
is less than 1 then word size is not taken into account.
* @param prefix the prefix to be found
* @param size the length that the word must equal or
be greater than. If a value less than 1 is specified, all words
regardless of their
* characters size should be considered. In other words
if the size parameter is < 1 word size is disregarded in the
calculations.
* @param ignoreCase if true this will ignore case
differences when matching the strings. If false this
considers
* case differences when matching the strings
* @return A list of all strings that start with the
specified prefix
* @throws IllegalArgumentException if the specified
string is null or empty (Meaning contains no characters or only
white space)
public abstract Set
getWordsThatStartWith(String prefix, int size, boolean ignoreCase)
throws IllegalArgumentException;
}
AbstractFileMonitor
package homework;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
* A class with methods to monitor a text file.
public abstract class AbstractFileMonitor {
private MessageDigest messageDigest;
private int currentCheckSum;
private boolean hasChanged = false;
private long nextUpateTime = 0;
public AbstractFileMonitor(String path){
setFilePath(path);
}
* Updates the variables that correspond to the file
being monitored
* This function has been throttled such that it will
only update values every 250 ms. In other words successive calls to
this
* function in time intervals that are less than 250 ms
will yield no change.
* @throws IOException Thrown if any type of I/O
exception occurs while writing to the file
* @throws IllegalStateException If the {@link
#setFile(String)} method in not invoked with a proper file prior to
invocation of this
* @throws NoSuchAlgorithmException If the computer's
OS is missing the SHA-256 hashing algorithm
* method. In other words if no file is currently set
to be monitored.
public void update() throws IOException,
IllegalStateException, NoSuchAlgorithmException {
if(messageDigest ==
null){
messageDigest =
MessageDigest.getInstance("SHA-256");
}
if(nextUpateTime >
System.currentTimeMillis()) {
hasChanged =
false;
return;
}
nextUpateTime =
System.currentTimeMillis() + 250;
File file = new
File(getFilePath());
if(!file.exists())
return;
try (DigestInputStream dis = new DigestInputStream(new
FileInputStream(getFilePath()), messageDigest)) {
while (dis.read() != -1) ;
messageDigest = dis.getMessageDigest();
}
StringBuilder result = new StringBuilder();
for (byte b : messageDigest.digest()) {
result.append(String.format("%02x", b));
}
hasChanged = currentCheckSum !=
result.toString().hashCode();
currentCheckSum = result.toString().hashCode();
}
* Tests if the file being monitored has changed since
the last time {@link #update()} was invoked
public boolean hasChanged(){
return hasChanged;
}
public abstract void setFilePath(String path);
public abstract String getFilePath() throws
IllegalStateException;
}
FileTextReader
package homework;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Set;
public interface FileTextReader{
public String readText(String path) throws
IOException;
* @throws IOException Thrown if any type of I/O
exception occurs while writing to the file
public Set getAllLines(String path) throws
IOException;
* @throws IOException Thrown if any type of I/O
exception occurs while writing to the file
public String getLastLine(String path) throws
IOException;
}
FileTextWriter
package homework;
import java.io.IOException;
public interface FileTextWriter {
* @throws IOException Thrown if any type of I/O
exception occurs while writing to the file
* @throws IllegalArgumentException if the specified
string is null or empty (Meaning contains no characters or only
white space)
public void writeToFile(String string, String
path) throws IOException, IllegalArgumentException;
}
We need to create that two classes.
In: Computer Science
Research the range of contemporary issues teenagers face today. In a 500-750-word paper, choose one issue (besides teen pregnancy) and discuss its effect on adolescent behavior and overall well-being. Include the following in your submission:
In: Nursing
Part 1: Model Building
1. Submit both this word and excel file
2. Keep two decimal places for your answer
Using the data Reynolds.xls. The variables are defined as:
Sales (Y) =number of electronic laboratory scales sold
Months (X) =the number of months the salesperson has been employed
1. Develop the scatter plot using Sales as y axis and Months as x axis, and can you see the curvature?
2. Using a simple linear regression model to develop an estimated regression equation to predict the Sales. What is the adjusted-R square?
3. Using a second-order regression model to develop an estimated regression equation to predict the Sales. What is the adjusted-R square? (Hint: second-order regression model should look like: y=b0+b1X+b2X2, and we learnt it in Chapter 16)
4. Compare the adjusted-R square from 2 and 3, which one is larger? Which model is better? (Hint: we learn this in Chapter 15)
5. Use 4 diagrams to test the 5 model assumptions for the second-order regression model. Do you think they are violated? (Hint: we learn this in week 12 computer skill class)
| Months | Sales |
| 41 | 275 |
| 106 | 296 |
| 76 | 317 |
| 104 | 376 |
| 22 | 162 |
| 12 | 150 |
| 85 | 367 |
| 111 | 308 |
| 40 | 189 |
| 51 | 235 |
| 9 | 83 |
| 12 | 112 |
| 6 | 67 |
| 56 | 325 |
| 19 | 189 |
In: Statistics and Probability
Tobacco smoking (1500 Word)
Tobacco smoking has long been established as a serious public health concern in Australia. The Australian government and health groups have used a multi-pronged strategy to reduce smoking rates over time. Discuss the economic rationale for these strategies and their likely impact on the consumption of tobacco products and subsequent health outcomes. In your answer, include the following:
a. The operation of an excise tax on tobacco product sales, using demand and supply curves to explore its impact.
b. The role of anti-smoking education campaigns to address potential market failure.
|
Criteria |
|
Description of the issue |
|
Identification of relevant economic theory |
|
Use of analytic tools |
|
Clearly written and addresses all aspects of the question and is well researched. |
In: Economics
Please answer do not use picture and handwriting, please typing word. copy other answer
2.State and Local Government face three fundamental fiscal choices . Please list these choices , and using an example in a specified government program , explain how these choices interact with each other , if at all
1 ) The correspondence principle provides an understanding of how the services ( or public goods ) of government may be organized and delivered . Please describe this principle , and using examples , explain how it can be used in understanding which level of government provides a specific public good
In: Economics
In: Economics
1. Adam Smith argued that an invisible hand would harmonize self-interest (Smith’s word was self-love) with the common good. Did Bentham agree? Why or why not?
2. Bentham stated that humans are governed by two sovereign masters. What are the sovereign masters?
3. To whom or what was Malthus responding when he formulated the population principle?
4. Is it correct to say that a severe form of diminishing marginal returns is embedded in Malthus’s population principle? Why or why not?
5. What is the grim stationary state?
In: Economics
please do on word document
QUESTIOn 2
Hamilton Travel Corporation's (HTC) shareholders' equity section at December 31, 2020 appears below:
Shareholders' equity
Common shares, 1,000,000 shares authorized,
80,000 shares issued $720,000
Retained earnings 180,000
Total shareholders' equity $900,000
On June 30, 2021, the board of directors of HTC declared a 10% stock dividend, payable on July 31, 2021, to shareholders of record on July 15, 2021. The fair market value of HTC's shares on June 30, 2021, was $12 per share.
On December 1, 2021, the board of directors declared a 2-for-1 stock split effective December 15, 2021. HTC's shares were selling for $16 on December 1, 2021, before the share split was declared. Profit for 2021 was $225,000 and there were no cash dividends declared.
Instructions
(a) Prepare the journal entries on the appropriate dates to record the stock dividend and the stock split. Indicate the date of the entry and if no entry is required, write “no entry”.
(b) Fill in the amount that would appear in the shareholders' equity section for HTC at December 31, 2021, for the following items:
1. Common shares $____________
2. Retained earnings $____________
3. Total shareholders' equity $____________
4. Number of common shares issued _____________
In: Accounting
Fill up the blanks from the word bank
|
CLIENT |
NETWORK |
REQUESTS |
ORGANISATIONS |
CENTRAL |
|
HOME |
PEER |
CONNECT |
COMPUTERS |
CONNECTION |
|
RESOURCES |
PERIPHERAL |
INTERNET |
SHARED |
SOFTWARE |
|
DISKS |
WINDOWS |
OPERATING |
SIMPLE |
INSTALLED |
A client–server ________________ is a network that uses one or more computers as servers and all the remaining ___Computers_________ as clients. Each server is a powerful computer that contains ________________ to be shared with clients. Most ________________ use the client–server network for their LAN. A client–server network involves using a network ________________ system (NOS). A NOS allows the server to complete ________________ from clients for resources. The majority of the NOS is ________________ on the server but each client has NOS client software. The NOS ________________ software is used to send requests to the server.
A peer-to-peer network is a network where there is no ________________ server but each computer is both a server and a client. It is a ________________ network that usually connects less than ten computers. A peer-to-peer network is used in ________________ and small offices to share files, ________________ devices and one Internet ________________. In a peer-to-peer network each computer is considered a ________________because it is equal and shares resources with others without a server. Each user determines which resources on their computer are to be ________________. Operating systems such as ________________ XP, Vista and Mac OS have the ________________ to operate a peer-to-peer network. A P2P is an Internet peer-to-peer network on which users ________________ directly to each other’s hard ________________ and exchange files over the ________________.
In: Computer Science