Advertisement
narimetisaigopi

Untitled

Mar 20th, 2024
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. void main() {
  2. Greetings greetings =
  3. Greetings(howManyGreets: 15, message: "Happy Holi", walletBalance: 10);
  4. print(greetings.getMyBalance());
  5. greetings.greet();
  6. print(greetings.getMyBalance());
  7. greetings.greet();
  8. print(greetings.getMyBalance());
  9. greetings.greet();
  10. }
  11.  
  12. class Greetings {
  13. int howManyGreets = 0;
  14. String message = "";
  15. int walletBalance = 0;
  16. Greetings(
  17. {this.howManyGreets = 0, this.message = "", this.walletBalance = 0});
  18.  
  19. greet() {
  20. if (walletBalance > 1) {
  21. for (int i = 0; i < howManyGreets; i++) {
  22. walletBalance--;
  23. print("Greeting: $message");
  24. }
  25. } else {
  26. print("You dont have sufficient balance");
  27. }
  28. }
  29.  
  30. getMyBalance() {
  31. return walletBalance;
  32. }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement