Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Курсовая работа / InternetConnection / src / ic / core / ComputerSpecialist
.java /*
* ComputerSpecialist.java
*
* Created on April 20, 2007, 2:24 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package ic.core;
/**
*
* @author adm
*/
public class ComputerSpecialist {
public static final float S_LOW_COST = 50;
public static final float S_MEDIUM_COST = 100;
public static final float S_HIGH_COST = 150;
private final String secretSpecialistCode = "xRw#dm)f%3&";
public enum Price {
low,
medium,
high
}
String name = "Bill Gates";
public ComputerSpecialist(String name) {
this.name = name;
}
public String getName() {
return name;
}
public float getSoftwareInstallationPrice(SoftwarePackage sp) {
if (sp.installed)
return 0;
if(sp.price < 50)
return S_HIGH_COST;
if(sp.price < 100)
return S_MEDIUM_COST;
if(sp.price < 500)
return S_LOW_COST;
return S_HIGH_COST;
}
/**
* returns false when client has no cash to pay for the work
*/
public boolean install (SoftwarePackage sp, Budget b) {
float myPrice = getSoftwareInstallationPrice(sp);
if(b.cash() < myPrice)
return false;
if(sp.installed)
return true;
b.decreaseCash(myPrice);
sp.startInstallation(this.secretSpecialistCode);
sp.setInstalledBy("Specialist "+ this.name);
return true;
}
}
* ComputerSpecialist.java
*
* Created on April 20, 2007, 2:24 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package ic.core;
/**
*
* @author adm
*/
public class ComputerSpecialist {
public static final float S_LOW_COST = 50;
public static final float S_MEDIUM_COST = 100;
public static final float S_HIGH_COST = 150;
private final String secretSpecialistCode = "xRw#dm)f%3&";
public enum Price {
low,
medium,
high
}
String name = "Bill Gates";
public ComputerSpecialist(String name) {
this.name = name;
}
public String getName() {
return name;
}
public float getSoftwareInstallationPrice(SoftwarePackage sp) {
if (sp.installed)
return 0;
if(sp.price < 50)
return S_HIGH_COST;
if(sp.price < 100)
return S_MEDIUM_COST;
if(sp.price < 500)
return S_LOW_COST;
return S_HIGH_COST;
}
/**
* returns false when client has no cash to pay for the work
*/
public boolean install (SoftwarePackage sp, Budget b) {
float myPrice = getSoftwareInstallationPrice(sp);
if(b.cash() < myPrice)
return false;
if(sp.installed)
return true;
b.decreaseCash(myPrice);
sp.startInstallation(this.secretSpecialistCode);
sp.setInstalledBy("Specialist "+ this.name);
return true;
}
}
Соседние файлы в папке core