Guest User

Untitled

a guest
Nov 16th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. class Microphone {
  2.  
  3. // instance variables or member variables
  4. String name;
  5. String color;
  6. int model;
  7.  
  8. // constructor
  9. // Microphone(String name, String color, int model) {
  10. // this.name = name;
  11. // this.color = color;
  12. // this.model = model;
  13. // }
  14. // shortend constructor
  15. Microphone(this.name, this.color, this.model);
  16. // named constructor
  17. Microphone.initialie() {
  18. name = 'Blue Yeti 2nd edition';
  19. model = 7382;
  20. }
  21.  
  22. bool isOn() => true;
  23. int modelNumber() => model;
  24.  
  25. void turnOn() {
  26. print('$name is on');
  27. }
  28. void turnOff() {
  29. print('$name is turned Off');
  30. }
  31. void setVolume(){
  32. print('$name with color: $color volume is up');
  33. }
  34.  
  35. String get getName => name; // getter
  36. set setName(String value) => name = value; // setter
  37. }
  38.  
  39. main () {
  40. var mic = new Microphone('Blue Yeti', 'Gold', 1903); // create the actual object of type mic
  41.  
  42. mic.setName = 'Blue Yeti setter';
  43. print(mic.getName);
  44.  
  45.  
  46. // mic.name = "Blue Yeti";
  47. //mic.color = 'Gold';
  48. //mic.model = 1903;
  49.  
  50. // print (mic);
  51. // mic.turnOn();
  52. // mic.turnOff();
  53. // mic.setVolume();
  54.  
  55. // var micSecond = new Microphone.initialie();
  56. // print(micSecond.name);
  57. }
Add Comment
Please, Sign In to add comment