Skip to content

Instantly share code, notes, and snippets.

@mohamedagamy
Forked from udacityandroid/Method 1
Created August 13, 2016 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohamedagamy/d881db4a6378fda9f09923d9ec9cac4f to your computer and use it in GitHub Desktop.
Save mohamedagamy/d881db4a6378fda9f09923d9ec9cac4f to your computer and use it in GitHub Desktop.
Android Development for Beginners : Define a Method
private String createCalendarEventReminder(String eventName, String location, int minutesAway) {
String reminder = "You have an upcoming event in " + minutesAway + " minutes.";
reminder = reminder + " It is " + eventName + " held at " + location + ".";
return reminder;
}
private int deductPoints(int pointsUsed) {
// Everyone starts with 100 points
int numberOfPoints = 100 - pointsUsed;
return numberOfPoints;
}
private String findTotalTripLength(int distanceOfFirstTrip, int distanceOfSecondTrip, int distanceOfThirdTrip) {
// Assume we need 2 miles to go to our friend's home (where the trip will start).
int totalLength = 2;
// Then start adding in the trip length.
totalLength = totalLength + distanceOfFirstTrip + distanceOfSecondTrip + distanceOfThirdTrip;
// Form a string to display the total trip length.
String message = "The total trip will be: " + totalLength + " miles.";
return message;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment