Create a class called triplestring

Assignment Help JAVA Programming
Reference no: EM131598070

Assignment - A Triple String Class

Make sure you have read and understood
bothmodules AandBthis week, and
module 2R - Lab Homework Requirements
A Simple Class: TripleStringUnderstand 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 staticmembers 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 MethodsDefault 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.javafile. 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.*; import java.lang.Math; 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()
Instantiatefour or moreTripleStringobjects, some of them using the default constructor, some using the constructor that takes parameters.
Immediatelydisplayall objects.
Mutateone or more members of every object.
Displayall objects a second time.
Do two explicitmutator tests.For each, call amutatorin an if/else statement which prints one message if the call is successful and a different message if the call fails.
Make twoaccessor callsto 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.

Reference no: EM131598070

Questions Cloud

Describe the key elements of compliance plan : You have just been hired as a compliance officer for your healthcare organization, and you have discovered that the food services department of the organization
In what way does husserls concept of ontology related : Identify the forum topic you selected, and summarize the contents of the existing forum posts for that topic.
Analyze the disadvantages of the instrument : A good place to start to evaluate actual performance is to look to the performance appraisal to determine if and by how much an employee's performance deviates.
Rationale and tactics of space-pervading processes : Explain the rationale and tactics of space-pervading processes by business firms seeking to influence consumer demand.
Create a class called triplestring : 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
Which motivating factors or concepts is important to workers : Which of following motivating factors or concepts is important to workers, regardless of their national culture? Emotional intelligence has been shown to be __.
The creation of a viable doctoral dissertation : The ability to identify these points is one of the first skills required in the creation of a viable doctoral dissertation.
What annual inflation rate : This is equivalent to what annual inflation rate, compounded annually?
Write a program which counts the number of times : Write a program which counts the number of times a given letter (supplied by the user) appears in a file. Hint: Use .charAt() and the File class

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd