CMPUT 301

Software Engineering

Lab 1


Lab 1 Slides

Instructions

Download and install Android Studio from the official Android website

https://developer.android.com/studio

Check for specific installation guide unique to your Operating System

https://developer.android.com/studio/install

Walkthrough

  1. Create a new LonelyTwitter project (File > New > New Project > Select "Empty Views Activity"). Make sure that the project language is Java, not Kotlin!

  2. Create Tweet Class (Click > New > Java Class)

  3. Make attributes (Date date & String message) (use alt+enter (windows) or Option-Enter (Mac) to include/import any packages)
    • Note: Access modifiers
      • private= class only
      • No modifier = within package
      • protected = within package and through inheritance
      • public = everyone!
  4. Create two Constructors (one with the only Message and the other with Date+Message as arguments) and use Date = new Date() (current date and time) for the first constructor (the Default value for date).
  5. Note: Java Object Class (everything extends it, calls its constructor and it has built-in methods like toString())
  6. Note: the this keyword (message = message doesn't do anything!)
  7. Make a regular tweet in MainActivity (pass in an empty string)

  8. Getters and setters

  9. Inheritance

  10. Make ImportantTweet child class (extends Tweet)

    • call super in both of ImportantTweet's constructors
  11. Now have access to the parent's methods and attributes. except constructors! (try and make an important Tweet)
ImportantTweet(String message){
        super(message);
    }

ArrayList tweetList = new ArrayList(); tweetList.add(normalTweet);

public interface Tweetable {
     public String getMessage();
     public Date getDate();
   }

Lab1 Participation Exercise Requirements

  1. Add three new model classes to LonelyTwitter: the first should be an abstract base class which represents the current mood. The second and third should be non-abstract classes which represent different moods (Ex: happy, sad, etc.) and inherit from the abstract class.
  2. Each mood should have a date and getters and setters to access the date.
  3. A constructor which sets the date to a default and a constructor which takes a date as an argument should be provided.
  4. Encapsulation should be followed.
  5. Each mood should have a method which returns a string representing that mood.
  6. Your new code should have examples of classes, methods, attributes, access modifiers, encapsulation, constructors, inheritance and abstract base classes.

Submission

Note: Running the project is not necessary.

Zip the project and upload it to eClass.