Question: IN KOTLIN PLZ AND AND Create a class StringReplacer which stores a single sfob and replaces it with new strings if they have the same
IN KOTLIN PLZ

AND

AND

Create a class StringReplacer which stores a single sfob and replaces it with new strings if they have the same length. Here's how it should work. Provide a primary constructor taking a single non-nutwsthe that sets the initial state of the stringReplacer. The saved string should be private, so do not provide a setter or getter for it. Also provide a method replace that accepts a single non-ncute stting. If the String passed to replace is the same length as the saved string, then replace the saved String. Otherwise, do not replace the saved Str-ing. Either way, return the saved String. When complete, here is how your class should work: Create a public class Less ThanSaved. Your constructor should accept a single Long parameter which you should store in a private field. Do not provide setters or getters for that value. You should also provide a public method is Less than that accepts a single Long parameter and returns true if the value passed to s ess phath is strictly less than the value stored by the object. When complete, here is how your class should work: 1 val first = LessThanSaved (5L) 2 val second = LessThanSaved (8L) 3 println(first. isLessThan (8L))// prints false 4 println(first. isLessThan (5L))/7 prints false 5 println(second. isLessThan (11L))// prints drue 6 println(second. isLessThan (42L))// princs falssi Define a class named Building with two instance variables: an String called name and a Int called capacity. Provide a primary constructor that sets both fields with the name as its first parameter. Provide a getter for the name, and both a getter and setter for the capacity. Finally, reject negative and zero capacity values using require, both in the constructor (init block) and in the setter, before you modify the capacity
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
