Тестирование программы
Тестирование проводилось вручную методом черного ящика. Найденные ошибки были устранены. Программа может считаться работоспособной.
Выводы:
В ходе работы мы разработали программу, моделирующую процесс организации компьютеризированного рабочего места на дому с подключением Интернет. В данный процесс вошли не только закупка компьютерного оборудования, мебели и программного обеспечения, но также и его настройка. Настройку можно осуществлять самостоятельно, но вероятность корректной настройки – учтена и в программе составляет 14%.
Выполнение работы оказалось полезным для обучения моделирования жизненных процессов при помощи программных систем.
Приложение 1: Исходный текст программы
Приведены только основные классы логики
/*
* Budget.java
*
* Created on April 20, 2007, 12:24 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package ic.core;
/**
*
* @author adm
*/
public class Budget {
private float cash;
public boolean decreaseCash(float c) {
if ( c <= cash ) {
cash -= c;
return true;
}
else
return false;
}
public float cash() {
return cash;
}
/** Creates a new instance of Budget */
public Budget(float startValue) {
this.cash = startValue;
}
}
/*
* Human.java
*
* Created on April 20, 2007, 3:01 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package ic.core;
import ic.core.U;
/**
*
* @author adm
*/
public class Human {
Furniture f = null;
Computer pc = null;
String name = null;
Budget b = null;
IProvider ip = null;
IConnection ic = null;
public IProvider getIProvider () {
return this.ip;
}
public IConnection getIConnection() {
return this.ic;
}
public boolean buyIConnection (IProvider ipr, IConnection ico) {
if(this.ic != null || this.ip != null)
return true;
if(this.b.cash() < ico.getMonthFee())
return false;
this.ip=ipr;
this.ic=ico;
return true;
}
/** Creates a new instance of Human */
public Human(String name, float cash) {
this.name = name;
this.b = new Budget(cash);
U.log("Human was born. His name is: "+name+" Cash flow: "+cash+"\n");
}
public String getName() {
return this.name;
}
public Budget getBudget() {
return b;
}
public Computer getPC() {
return pc;
}
public Furniture getFurniture() {
return f;
}
public boolean hasComputer() {
if(pc == null)
return false;
else
return true;
}
public boolean hasFurniture() {
if(f == null)
return false;
else
return true;
}
public boolean buyComputer(Computer.Productivity p, ComputerSalesCompany comp, String computer) {
boolean bought = comp.saleComputer(this.b, computer);
if(bought) {
this.pc = new Computer(p);
return true;
}
else return false;
}
public boolean buyComputer(Computer c) {
if (this.pc != null)
return true;
if (c.getPrice() < b.cash()) {
this.pc = new Computer(c.getProductivity());
pc.setName(c.getName());
pc.setPrice(c.getPrice());
pc.setSeller(c.getSeller());
b.decreaseCash(pc.getPrice());
return true;
}
else {
return false;
}
}
public boolean buyFurniture(Furniture c) {
if (this.f != null)
return true;
if (c.getPrice() < b.cash()) {
this.f = new Furniture(c.getBeauty());
f.setName(c.getName());
f.setPrice(c.getPrice());
f.setSeller(c.getSeller());
b.decreaseCash(f.getPrice());
return true;
}
else {
return false;
}
}
public boolean buyFurniture (Furniture.Beauty b, FurnitureSalesCompany comp, String furniture) {
boolean bought = comp.saleFurniture(this.b, furniture);
if(bought) {
this.f = new Furniture(b);
return true;
}
else return false;
}
public boolean buySoftwarePackage (SoftwarePackage sp) {
if (pc!=null & pc.getSoftwarePackage() == null) {
pc.setSoftwarePackage(sp);
b.decreaseCash(sp.getPrice());
return true;
}
return false;
}
public boolean buySoftwarePackage(float packagePrice, String osName, String officeName) {
if(b.cash() < packagePrice)
return false;
if(pc==null)
return false;
SoftwarePackage s = new SoftwarePackage(osName, officeName, packagePrice);
pc.setSoftwarePackage(s);
return true;
}
public boolean installSoftwarePackage() {
//SoftwarePackage.InstallationWay iway = SoftwarePackage.InstallationWay.myself;
if(this.pc == null )
return false;
if(this.pc.getSoftwarePackage() == null)
return false;
//this.pc.getSoftwarePackage().startInstallation(iway);
return true;
}
public boolean callSpecialist(ComputerSpecialist cs) {
if(cs.install(this.pc.getSoftwarePackage(), b))
return true;
else
return false;
}
}
/*
* Computer.java
*
* Created on April 20, 2007, 1:21 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package ic.core;
/**
*
* @author adm
*/
public class Computer {
public static final float M_LOW_COST = 500;
public static final float M_MEDIUM_COST = 1000;
public static final float M_HIGH_COST = 2000;
String seller = "Computer house inc.";
String name="IBM PC compatible";
float price = 0;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public String getSeller() {
return this.seller;
}
public void setSeller(String s) {
this.seller = s ;
}
public float getPrice() {
return this.price;
}
public void setPrice(float s) {
this.price = s ;
}
public enum Productivity {
low,
medium,
high
}
private Productivity prod;
public Productivity getProductivity() {
return prod;
}
public Computer() {
prod = Productivity.low;
}
public Computer(Productivity p) {
prod = p;
}
public Productivity peformance() {
return prod;
}
public float getCostType() {
switch(prod) {
case low:
return M_LOW_COST;
case medium:
return M_MEDIUM_COST;
case high:
return M_HIGH_COST;
default:
return -1;
}
}
// Software Equipment
SoftwarePackage sp = null;
public boolean setSoftwarePackage(SoftwarePackage sp) {
this.sp = sp;
return true;
}
public SoftwarePackage getSoftwarePackage() {
return sp;
}
}
package ic.core;
/*
* Funiture.java
*
* Created on April 20, 2007, 2:01 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
/**
*
* @author adm
*/
public class Furniture {
String seller = "Wood and drill Inc.";
String name="Wooden 1";
float price = 0;
public static final float M_LOW_COST = 300;
public static final float M_MEDIUM_COST = 700;
public static final float M_HIGH_COST = 1100;
public enum Beauty {
low,
medium,
high
}
private Beauty beauty;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public String getSeller() {
return this.seller;
}
public void setSeller(String s) {
this.seller = s ;
}
public float getPrice() {
return this.price;
}
public void setPrice(float s) {
this.price = s ;
}
public Furniture() {
beauty = Beauty.low;
}
public Furniture(Beauty b) {
beauty = b;
}
public Beauty getBeauty() {
return beauty;
}
public float getCost() {
switch(beauty) {
case low:
return M_LOW_COST;
case medium:
return M_MEDIUM_COST;
case high:
return M_HIGH_COST;
default:
return -1;
}
}
}
/*
* IProvider.java
*
* Created on April 22, 2007, 6:07 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package ic.core;
import java.util.*;
/**
*
* @author adm
*/
public class IProvider {
String name = "prov";
/** Creates a new instance of IProvider */
public IProvider(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setName(String n) {
this.name = n;
}
HashMap priceList = new HashMap();
public void addPricePosition(IConnection ic) {
priceList.put(priceList.keySet().size()+1, ic);
}
public HashMap getPriceList() {
return this.priceList;
}
}
1 - данные указаны для розницы в г. Санкт-Петербург на апрель 2007 года
2 - указаны условные индексы производительности для одноядерных процессоров по шкале компании AMD.