subject

Understand the Application The assignment is to first create a class called TripleString. TripleString will consist of three private member Strings as its basic data. There will be few instance methods to support that data.
Once defined, we will use it to instantiate TripleString objects that can be used in our main() method. In a later assignment, the TripleString class will help us create a more involved application.
TripleString will contain three private member Strings as its main data: string1, string2, and string3. We will also add a few public static member such as final int MAX_LEN and MIN_LEN. These represents the maximum and minimum length that our class will allow any of its strings to be set to. We can use these static members in the TripleString method whose job it is to test for valid strings (see below).
The Program Spec
Class TripleString Spec
Private Class Instance Members:
String string1
String string2
String string3
All legal strings should be between 1 and 50 characters.
As stated in the modules, we never want to see a literal in our methods. So the class should have static members to hold values for the limits described above, as well as default values for any field that is construct-ed using illegal arguments from the client. These are put in the public static section.
Public Class Static Constants (declare to be final):
MIN_LEN = 1
MAX_LEN = 50
DEFAULT_STRING = " (undefined) "
Public Instance Methods
Default Constructor
TripleString() -- a default constructor that initializes all members to DEFAULT_STRING.
Paramteter-Taking Constructor
TripleString(String str1, String str2, String str3) -- a constructor that initializes all members according to the passed parameters. It has to to be sure each String satisfies the class requirement for a member String. It does this, as in the modules, by calling the mutators and taking possible action if a return value is false. If any passed parameter does not pass the test, a default String should be stored in that member.
Mutators/Accessor
set()s and get()s for these members. Mutators in our course are named using the convention as follows: setString1( ... ), setString3( ... ), etc. Likewise with accessors: getString2(). We need an accessor and mutator for each individual String member, so three pairs of methods in this category. Mutators make use of the private helper method validString(). When a mutator detects an invalid String, no action should be taken. The mutator returns false and the existing String stored in that member prior to the call remains in that member, not a new default String.
String toString() - a method that returns a String which contains all the information (three strings) of the TripleString object. This String can be in any format as long as it is understandable and clearly formatted.
Private Static Helper Methods
boolean validString( String str ) -- a helper function that the mutators can use to determine whether a String is legal. This method returns true if the string is not null and its length is between MIN_LEN and MAX_LEN (inclusive). It returns false, otherwise.
Where it All Goes
TripleString should be a class distinct from (and not contained within) your main class (which we call Foothill). You can create the TripleString class as a non-public class directly in your client Foothill. java file. This makes it a sibling class, capable of being used by any other classes in the file (of which there happens to be only one: Foothill).
You type it directly into that file; do not ask Eclipse to create a new class for you or it will generate a second .java file which we don't want right now. In other words, Foothill. java will look like this:
import java. util.*;
public class Foothill
{
// main class stuff ...
}
class TripleString
{
// TripleString class stuff ...
}
As you see, TripleString is to be defined after, not within, the Foothill class definition. This makes it a sibling class, capable of being used by any other classes in the file (of which there happens to be only one: Foothill).
The Foothill main()
Instantiate four or more TripleString objects, some of them using the default constructor, some using the constructor that takes parameters.
Immediately display all objects.
Mutate one or more members of every object.
Display all objects a second time.
Do two explicit mutator tests. For each, call a mutator in an if/else statement which prints one message if the call is successful and a different message if the call fails.
Make two accessor calls to demonstrate that they work.
More:
Be sure that all output is descriptive. Use labels to differentiate your output sections and full sentences in your mutator/accessor tests.
No user input should be done in this program.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:50
Write a 3-4 page apa formatted paper comparing your organization’s it strategy with the best practices outlined in your course text. content should include, but not be limited to: developing and delivering on the it value, developing it strategy for the business value and linking it to business metrics. your paper should include an abstract and a conclusion and a reference page with 3-5 references
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
1. which of the following is not an example of an objective question? a. multiple choice. b. essay. c. true/false. d. matching 2. why is it important to recognize the key word in the essay question? a. it will provide the answer to the essay. b. it will show you a friend's answer. c. it will provide you time to look for the answer. d. it will guide you on which kind of answer is required.
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words.size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words.size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
A. in packet tracer, only the server-pt device can act as a server. desktop or laptop pcs cannot act as a server. based on your studies so far, explain the client-server model.
Answers: 2
You know the right answer?
Understand the Application The assignment is to first create a class called TripleString. TripleStr...
Questions
question
Mathematics, 29.06.2021 05:00
question
English, 29.06.2021 05:10
question
Mathematics, 29.06.2021 05:10
question
Mathematics, 29.06.2021 05:10
Questions on the website: 13722361