Friday 1 October 2021

Exercise Create Your own Class in GroovyScripting groovy traing videos in telugu 09

 Watch This Video


[Exercise] Create Your own Class
In this exercise you are going to create your own class and start to think about what your class would contain. There is no 1 correct answer for this. Follow the rules and see what you come up with.

Create a class called Tweet
Add properties to this class.
What properties would be present in a class that holds information about a tweet
Think about what their data types would be
What methods would go in this class?
How about a constructor to create a new tweet.
How about methods to change some of your properties?
How about a toString method (or AST Transformation)
Create a script called Twitter.
In this script create one or more Tweets.
print the Tweet instances to the console (and have their string representations shown)

Create a file called Tweet.groovy.
Inside this file create a class called Tweet (the one you created above)

class Tweet{
String username
String text
Integer retweets
Integer favorites
Date createdOn

public Tweet(String user, String tweet){

createdOn=new Date()

void addToRetweets(){
void addToFavorite(){
def whatsapp =new whatsapp("sudheer","Helomsg")
print whatsapp

No comments:

Post a Comment

Note: only a member of this blog may post a comment.