revise it to my own one.(I got a example)

revise it to my own one.(I got a example)

xxx.java
public class xxx {
public static void main(String[] args) {
TripleString t1 = new TripleString(); //default constuctor
TripleString t2 = new TripleString(“one”, “two”, “three”); //valid values in parameterizied constructor
TripleString t3 = new TripleString(null, “”, “xyz”); //invalid values for 2 parameters
TripleString t4 = new TripleString(null, null, null); //invalid parameters for all 3
System.out.println(“Displaying the 4 triple strings created using different constructors”);
System.out.println(“t1 using default constructor : \n” + t1);
System.out.println(“t2 with all valid values: \n” + t2);
System.out.println(“t3 with 2 parameters invalid: \n” + t3);
System.out.println(“t4 with all invalid parameters: \n” + t4);
//mutate all objects
System.out.println(“\nUsing mutators to change each of the objects”);
t1.setString1(“potato”);
t2.setString2(“four”);
t3.setString3(“chips”);
t4.setString1(“pen”);
System.out.println(“t1: ” + t1);
System.out.println(“t2: ” + t2);
System.out.println(“t3: ” + t3);
System.out.println(“t4: ” + t4);
System.out.println();
//explicit test
if(t3.setString1(“watermelon”))
System.out.println(“t3.setString1(\”watermelon\”) was succesful”);
else
System.out.println(“t3.setString1(\”watermelon\”) was NOT succesful”);
if(t3.setString3(“”))
System.out.println(“t3.setString1(\”\”) was succesful”);
else
System.out.println(“t3.setString1(\”\”) was NOT succesful”);
System.out.println(“t2.getString1() = ” + t2.getString1());
System.out.println(“t2.getString2() = ” + t2.getString2());
}
}
class TripleString
{
private String string1;
private String string2;
private String string3;
public static final int MIN_LEN = 1;
public static final int MAX_LEN = 50;
public static final String DEFAULT_STRING = ” (undefined) “;
public TripleString()
{
string1 = DEFAULT_STRING;
string2 = DEFAULT_STRING;
string3 = DEFAULT_STRING;
}
public TripleString(String s1, String s2, String s3)
{
if(!setString1(s1))
string1 = DEFAULT_STRING;
if(!setString2(s2))
string2 = DEFAULT_STRING;
if(!setString3(s3))
string3 = DEFAULT_STRING;
}
public boolean setString1(String s1) {
if(validString(s1))
{
this.string1 = s1;
return true;
}
else
return false;
}
public boolean setString2(String s2) {
if(validString(s2))
{
this.string2 = s2;
return true;
}
else
return false;
}
public boolean setString3(String s3) {
if(validString(s3))
{
this.string3 = s3;
return true;
}
else
return false;
}
public String getString1() {
return string1;
}
public String getString2() {
return string2;
}
public String getString3() {
return string3;
}
public String toString()
{
return “[ string1: ” + string1 + “, string2: ” + string2 + “, string3: ” +string3 + ” ]”;
}
private static boolean validString(String s)
{
if(s != null && s.length() >= MIN_LEN && s.length() <= MAX_LEN) return true; else return false; } }

Calculate your order
275 words
Total price: $0.00

Top-quality papers guaranteed

54

100% original papers

We sell only unique pieces of writing completed according to your demands.

54

Confidential service

We use security encryption to keep your personal data protected.

54

Money-back guarantee

We can give your money back if something goes wrong with your order.

Enjoy the free features we offer to everyone

  1. Title page

    Get a free title page formatted according to the specifics of your particular style.

  2. Custom formatting

    Request us to use APA, MLA, Harvard, Chicago, or any other style for your essay.

  3. Bibliography page

    Don’t pay extra for a list of references that perfectly fits your academic needs.

  4. 24/7 support assistance

    Ask us a question anytime you need to—we don’t charge extra for supporting you!

Calculate how much your essay costs

Type of paper
Academic level
Deadline
550 words

How to place an order

  • Choose the number of pages, your academic level, and deadline
  • Push the orange button
  • Give instructions for your paper
  • Pay with PayPal or a credit card
  • Track the progress of your order
  • Approve and enjoy your custom paper

Ask experts to write you a cheap essay of excellent quality

Place an order