Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LAB Assignment 6 - A Three Strin X + X C foothillcollege.instructure.com/courses/22185/assignments/685179#submit R . .. Available Oct 26 at 8am - Nov 12 at 2pm

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
LAB Assignment 6 - A Three Strin X + X C foothillcollege.instructure.com/courses/22185/assignments/685179#submit R . .. Available Oct 26 at 8am - Nov 12 at 2pm Grade: 0 (20 pts possible) Fall 2022 FOOTHILL Graded Anonymously: no COLLEGE Home O Simple Syllabus Assignment 6 - A Three String Class Comments: No Comments Account Modules Make sure you have read and understood the chapter this week before submitting this assignment. Hand in only one program, please. Discussions Dashboard A Simple Class: ThreeString Grades 6 Understand the Application Courses Foothill Zoom The assignment is to first create a class called ThreeString. ThreeString will consist of three Foothill Tutoring private member Strings as its basic data. There will be few instance methods to support that Calendar Library data. Announcements Once defined, we will use it to instantiate ThreeString objects that can be used in our main() Inbox method. In a later assignment, the ThreeString class will help us create a more involved application. History ThreeString 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 Studio of its strings to be set to. We can use these static members in the ThreeString method whose job it is to test for valid strings (see below). Help The Program Spec 54OF Sunny Q Search LOOL O 12:16 PM O OR 2 11/12/2022LAB Assignment 6 - A Three Strin X + X C A foothillcollege.instructure.com/courses/22185/assignments/685179#submit G R . .. Fall 2022 The Program Spec FOOTHILL COLLEGE Home Class ThreeString Spec O Simple Syllabus Private Class Instance Members: . String string1 Account Modules . String string2 Discussions . String string3 Dashboard Grades 6 All legal strings should be between 1 and 50 characters. Foothill Zoom We never want to see a literal in our methods. So the class should have static members to Courses hold values for the limits described above, as well as default values for any field that is Foothill Tutoring construct-ed using illegal arguments from the client. These are put in the public static Calendar Library section. Public Class Static Constants (declare to be final): Announcements Inbox . MIN_LEN = 1 . MAX_LEN = 50 . DEFAULT_STRING = " (undefined) " History Public Instance Methods Default Constructor Studio ThreeString () -- a default constructor that initializes all members to DEFAULT_STRING. Help Paramteter-Taking Constructor 54OF Q Search LDe 12:16 PM O 2 Sunny 11/12/2022LAB Assignment 6 - A Three Strin X + X C foothillcollege.instructure.com/courses/22185/assignments/685179#submit G R . .. construct-ed using illegal arguments from the client. These are put in the public static Fall 2022 section. FOOTHILL COLLEGE Home Public Class Static Constants (declare to be final): O . MIN_LEN = 1 Simple Syllabus . MAX_LEN = 50 Account Modules . DEFAULT_STRING = " (undefined) " Discussions Public Instance Methods Dashboard Grades 6 Default Constructor Courses Foothill Zoom ThreeString () -- a default constructor that initializes all members to DEFAULT_STRING. Foothill Tutoring Paramteter-Taking Constructor Calendar ThreeString (String str1, String str2, String str3) -- a constructor that initializes all members Library according to the passed parameters. It has to to be sure each String satisfies the class Announcements requirement for a member String. It does this, by calling the mutators and taking possible Inbox 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. History Mutators/Accessor set()s and get()s for these members. Mutators in our course are named using the convention Studio 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 Help mutator detects an invalid String, no action should be taken. The mutator returns false and 54OF Q Search LOCLE O 12:16 PM 2 Sunny 11/12/2022LAB Assignment 6 - A Three Strin X + X C foothillcollege.instructure.com/courses/22185/assignments/685179#submit G R . .. LIIs category. Iviuidols make use of the private Tierpel metou valuJug(). Vriend Fall 2022 mutator detects an invalid String, no action should be taken. The mutator returns false and FOOTHILL COLLEGE the existing String stored in that member prior to the call remains in that member, not a new Home default String. O Simple Syllabus String toString() - a method that returns a String which contains all the information (three Account Modules strings) of the ThreeString object. This String can be in any format as long as it is understandable and clearly formatted. Discussions Dashboard Private Helper Method Grades 6 boolean validString( String str ) -- a helper function that the mutators can use to determine Courses Foothill Zoom 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. Foothill Tutoring Where it All Goes Calendar Library ThreeString should be a class distinct from (and not contained within) your main class (which Announcements we call Foothill). You can create the ThreeString class as a non-public class directly in your Inbox 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). History 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 Studio like this: import java.util.*; Help public class Foothill 54OF 12:16 PM Sunny Q Search LOCLAO O CR 2 11/12/2022LAB Assignment 6 - A Three Strin X + X C foothillcollege.instructure.com/courses/22185/assignments/685179#submit G R . .. like this: Fall 2022 FOOTHILL import java.util.*; COLLEGE Home public class Foothill O Simple Syllabus // main class stuff ... Account Modules class ThreeString Discussions Dashboard Grades 6 // ThreeString class stuff ... Courses Foothill Zoom As you see, ThreeString is to be defined after, not within, the Foothill class definition. This Foothill Tutoring makes it a sibling class, capable of being used by any other classes in the file (of which there Calendar happens to be only one: Foothill). Library Announcements The Foothill main() Inbox 1. Instantiate four or more ThreeString objects, some of them using the default constructor, some using the constructor that takes parameters. History 2. Immediately display all objects. 3. Mutate one or more members of every object. 4. Display all objects a second time. Studio 5. 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. 6. Make two accessor calls to demonstrate that they work. Help More: 54OF Sunny Q Search LOOL 12:16 PM O CR 2 11/12/2022

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions