Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Microphone {
- // instance variables or member variables
- String name;
- String color;
- int model;
- // constructor
- // Microphone(String name, String color, int model) {
- // this.name = name;
- // this.color = color;
- // this.model = model;
- // }
- // shortend constructor
- Microphone(this.name, this.color, this.model);
- // named constructor
- Microphone.initialie() {
- name = 'Blue Yeti 2nd edition';
- model = 7382;
- }
- bool isOn() => true;
- int modelNumber() => model;
- void turnOn() {
- print('$name is on');
- }
- void turnOff() {
- print('$name is turned Off');
- }
- void setVolume(){
- print('$name with color: $color volume is up');
- }
- String get getName => name; // getter
- set setName(String value) => name = value; // setter
- }
- main () {
- var mic = new Microphone('Blue Yeti', 'Gold', 1903); // create the actual object of type mic
- mic.setName = 'Blue Yeti setter';
- print(mic.getName);
- // mic.name = "Blue Yeti";
- //mic.color = 'Gold';
- //mic.model = 1903;
- // print (mic);
- // mic.turnOn();
- // mic.turnOff();
- // mic.setVolume();
- // var micSecond = new Microphone.initialie();
- // print(micSecond.name);
- }
Add Comment
Please, Sign In to add comment