Скачиваний:
17
Добавлен:
01.05.2014
Размер:
3 Кб
Скачать
package ic.core;
/*
 * SoftwarePackage.java
 *
 * Created on April 20, 2007, 2:09 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

import java.util.*;
/**
 *
 * @author adm
 */
public class SoftwarePackage {
    
    public HashMap packages;
    
    String name = "Software Package One";
    
    void initPackagesVariety() {
        packages = new HashMap();
        packages.put(10, "Free Linux + Open Office");
        packages.put(100, "Win XP + Open Office");
        packages.put(450, "Win Vista + MS Office 2007");
        
    }
    
    public enum InstallationWay {
        myself,
        specialist
    }
    
    public void setName(String name)  {
        this.name = name;
    }
    
    public String getName() {
        return this.name;
    }
    private final String secretSpecialistCode = "xRw#dm)f%3&";
    
    String operationSystem = null;
    String officePackage = null;
    float price = 0;
    
    boolean installed = false;
            
    public String getInstalled() {
        if (this.installed)
            return "YES";
        else 
            return "NO";
    }
    
    String installedBy = "--";
    public String getInstalledBy() {
        return this.installedBy;
    }
    
    /** Creates a new instance of SoftwarePackage */
    public SoftwarePackage(String OSName, String officeName, float price) {
        this.operationSystem = OSName;
        this.officePackage = officeName;
        this.price = price;
        
        initPackagesVariety();
    }
    
    public String getOSName() {
        return operationSystem;
    }
    
    public String getOfficeName() {
        return officePackage;
    }
    
    public float getPrice() {
        return price;
    }
    public void setInstalledBy(String ib) {
        this.installedBy = ib;
    }
    public boolean startInstallationMyself(String name) {
        if(this.installed)
            return true; // already installed
        
        if ( (int)(Math.random()*10)%7 == 0) {
            this.installed = true;
            this.installedBy = name;
            return true; //fine =) 14% is yours ;)
        }
        else {
            return false;
        }            
    }
    
    public boolean startInstallation(String secretSpecialistCode) {
        if (secretSpecialistCode.endsWith(this.secretSpecialistCode)) {
            this.installed = true ;
            this.installedBy = "Specialist. Code: "+secretSpecialistCode;
            return true;
        }
        
        return false;
    }
}
Соседние файлы в папке core