In week1 we'll start in the shallow end of the Apex pool, with some basic method construction, intake of arguments, and String manipulation. Strings are one of the primitive data types available in Apex.
Once you're ready to check an element of this challenge, just enter the following command into the terminal at your project directory's location (e.g. if you're using a ZS50 Sandbox the terminal will launch in the correct location):
zs50 check sayHello
Remember, you can also "scaffold" a blueprint class into your terminal window to help you get started via the command:
zs50 scaf sayHello
Create a public class SayHello
and, inside it...
Implement a method sayHi
that:
- Initialize a String type variable to 'Hello, World'
- write it to the Apex debug logs (hint: see the Apex System.debug())
- return the string
Implement a method sayMyName
that:
- returns a String set to your name.
Implement a method speak
that:
- takes a single String as an argument
- checks to make sure the argument is not
null
- if it is, return a String 'Invalid argument`.
- else:
- return the String, AFTER converting it to all lowercase (hint: see Apex String class)
Once your class and methods pass all validations you'll see a nice, if anti-climactic, little Success!
message.