Basic Structure of OOP
Key Concepts
2.21
public pet(String petName) { name = petName }
2.22
public Date(String dateYearMonthDay) { yearMonthDay = dateYearMonthDay }
2.26
public int getTotal() { return Total; }
2.33
public void increase(int points) { score+=points; //compound assignment statement }
2.36
My cat has green eyes.
2.37
2.41
2.43
2.44
2.45
2.48
if (amount <= 0) { System.out.println(“Use a positive amount rather than: ”+ amount); }else{ balance = balance + amount; }
2.54
2.56 2.57
Calling method
substring is a method. An index value of zero represents the first character of a string, so getLoginName takes the first four characters of the name string and the first three characters of the id string and then concatenates them together to form a new string. This new string is returned as the method’s result. For instance, if name is the string “Leonardo da Vinci” and id is the string “468366”, then the string “Leon468” would be returned by this method.
When I typed in “cat”+9+3, the system did not output the result of 9+3 but both 9 and 3. Why?