Created
October 7, 2014 15:19
-
-
Save OlgaKulikova/68adcc2d7bc9bce31143 to your computer and use it in GitHub Desktop.
The project Phones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Phone; | |
public class IPhone extends Phone { | |
public IPhone() { | |
System.out.println("IPhone constructor"); | |
touch = true; | |
hasWifi = true; | |
screenSize = 3; | |
} | |
@Override | |
final public void call(String number) { | |
super.call(number); | |
System.out.println("IPhone class is calling " + number); | |
} | |
@Override | |
public void sendSMS(String number, String message) { | |
super.sendSMS(number, message); | |
System.out.println("IPhone class is sending sms " + message + " to " + number); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Phone; | |
public class IPhone5 extends IPhone { | |
public IPhone5() { | |
System.out.println("IPhone5 constructor"); | |
screenSize = 4; | |
} | |
@Override | |
public void sendSMS(String number, String message) { | |
super.sendSMS(number, message); | |
System.out.println("IPhone5 class is sending sms " + message + " to " + number); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Phone; | |
public class MainClass { | |
public static void main(String[] args) { | |
Nokia3310 nokia = new Nokia3310(); | |
System.out.println("Nokia3310 screent size: " + nokia.getScreenSize()); | |
nokia.call("123-45-67"); | |
nokia.sendSMS("567-78-89", "text message"); | |
System.out.println("----------------------------------"); | |
IPhone iphone = new IPhone(); | |
System.out.println("IPhone screent size: " + iphone.getScreenSize()); | |
iphone.call("123-45-67"); | |
iphone.sendSMS("567-78-89", "text message"); | |
System.out.println("----------------------------------"); | |
IPhone5 iphone5 = new IPhone5(); | |
System.out.println("IPhone screent size: " + iphone5.getScreenSize()); | |
iphone5.call("123-45-67"); | |
iphone5.sendSMS("567-78-89", "text message"); | |
System.out.println("----------------------------------"); | |
SumsungS4 sumsungS4 = new SumsungS4(); | |
System.out.println("SumsungS4 screen size: " + sumsungS4.getScreenSize()); | |
sumsungS4.call("555-55-55"); | |
sumsungS4.sendSMS("555-55-55", "How are you?"); | |
sumsungS4.call("111-11-11"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Phone; | |
public class Nokia3310 extends Phone { | |
public Nokia3310() { | |
System.out.println("Nokia3310 constructor"); | |
touch = false; | |
hasWifi = false; | |
screenSize = 2; | |
} | |
@Override | |
public void call(String number) { | |
super.call(number); | |
System.out.println("Nokia3310 class is calling " + number); | |
} | |
@Override | |
public void sendSMS(String number, String message) { | |
super.sendSMS(number, message); | |
System.out.println("Nokia3310 class is sending sms " + message + " to " + number); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Phone; | |
// Модифицировать класс Phone так, чтобы он считал количество звонков и сообщений отдельно для каждого объекта. | |
public class Phone { | |
protected boolean touch; | |
protected boolean hasWifi; | |
protected int screenSize, callCount, smsCount; | |
public Phone() { | |
System.out.println("Phone constructor"); | |
} | |
public boolean isTouch() { | |
return touch; | |
} | |
public boolean isHasWifi() { | |
return hasWifi; | |
} | |
public int getScreenSize() { | |
return screenSize; | |
} | |
public void call(String number) { | |
callCount++; | |
System.out.println("Phone class is calling " + number); | |
System.out.println("Quantity of calls is " + callCount); | |
} | |
public void sendSMS(String number, String message) { | |
smsCount++; | |
System.out.println("Phone class is sending sms " + message + " to " + number); | |
System.out.println("Quantity of sms is " + smsCount); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Phone; | |
/* Написать класс наследник SamsungS4 с диагональю экрана 5 дюймов, | |
поддержкой Wifi и методом отправки SMS, | |
который будет дописывать к сообщению слово “Hello”. | |
*/ | |
public class SumsungS4 extends Phone { | |
public SumsungS4() { | |
System.out.println("SumsungS4 constructor"); | |
touch = true; | |
hasWifi = true; | |
screenSize = 5; | |
} | |
@Override | |
public void call(String number) { | |
super.call(number); | |
System.out.println("SumsungS4 class is calling " + number); | |
} | |
@Override | |
public void sendSMS(String number, String message) { | |
super.sendSMS(number, message); | |
System.out.println("SumsungS4 class is sending sms " + "Hello! " + message + " to " + number); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment