11package kylemartin .finalproject ;
22
3+ import javafx .collections .FXCollections ;
34import javafx .fxml .FXML ;
5+ import javafx .scene .control .ChoiceBox ;
46import javafx .scene .control .Label ;
7+ import javafx .scene .layout .AnchorPane ;
58
69public class ConfiguratorController {
10+ CustomizedComputer usersCustomizedComputer = new CustomizedComputer ();
11+
12+ /* Methods */
13+ public String setFieldToString (Double price ) {
14+ return price .toString ();
15+ }
16+
17+ // Main Screen
718 @ FXML
8- private Label welcomeText ;
19+ protected void OnMainScreenButtonClick () {
20+ intelScreen .setVisible (false );
21+ AMDScreen .setVisible (false );
22+ mainScreen .setVisible (true );
23+ processorName = "Processor" ;
24+ memoryName = "Memory" ;
25+ storageSpaceName = "Storage" ;
26+ graphicsName = "Graphics" ;
27+ operatingSystemName = "Operating System" ;
28+ opticalDriveName = "Optical Drive" ;
29+
30+ basePackagePrice = 0.0 ;
31+ processorPrice = 0.0 ;
32+
33+ updateLabels ();
934
35+ audioNameLabel .setText ("Audio Device" );
36+ speakersNameLabel .setText ("Speakers" );
37+ keyboardNameLabel .setText ("Keyboard" );
38+ mouseNameLabel .setText ("Mouse" );
39+ }
40+
41+ // AMD Screen
1042 @ FXML
11- protected void onHelloButtonClick () {
12- welcomeText .setText ("Welcome to JavaFX Application!" );
43+ public void OnAMDScreenButtonClick () {
44+ mainScreen .setVisible (false );
45+ intelScreen .setVisible (false );
46+ AMDScreen .setVisible (true );
47+ }
48+
49+ // Intel Screen
50+ @ FXML
51+ public void OnIntelScreenButtonClick () {
52+ mainScreen .setVisible (false );
53+ AMDScreen .setVisible (false );
54+ intelScreen .setVisible (true );
55+ usersCustomizedComputer .baseIntel .transformProcessorFields ();
56+
57+ processorName = usersCustomizedComputer .baseIntel .getProcessorName ();
58+ memoryName = usersCustomizedComputer .baseIntel .getMemoryName ();
59+ storageSpaceName = usersCustomizedComputer .baseIntel .getStorageSpaceName ();
60+ graphicsName = usersCustomizedComputer .baseIntel .getGraphicsName ();
61+ operatingSystemName = usersCustomizedComputer .baseIntel .getOperatingSystemName ();
62+ opticalDriveName = usersCustomizedComputer .baseIntel .getOpticalDriveName ();
63+
64+ processorPrice = usersCustomizedComputer .baseIntel .getProcessorPrice ();
65+ memoryPrice = usersCustomizedComputer .baseIntel .getMemoryPrice ();
66+ storageSpacePrice = usersCustomizedComputer .baseIntel .getStorageSpacePrice ();
67+ graphicsPrice = usersCustomizedComputer .baseIntel .getGraphicsPrice ();
68+ operatingSystemPrice = usersCustomizedComputer .baseIntel .getOperatingSystemPrice ();
69+ opticalDrivePrice = usersCustomizedComputer .baseIntel .getOpticalDrivePrice ();
70+
71+ basePackagePrice = 499.0 ;
72+
73+ updateLabels ();
74+
75+ // CPU Choice
76+ cpuChoiceBox .setItems (FXCollections .observableArrayList ("Intel Celeron G1610 2.3GHz + $0.0" ,
77+ "Intel Celeron G1620 2.7GHz + $50.00" ,
78+ "Intel Celeron G1630 2.8GHz + $90.00" ,
79+ "Intel Celeron G1820 2.7GHz + $105.00" ,
80+ "Intel Celeron G1830 2.8GHz + $130.00" ));
81+ cpuChoiceBox .setOnAction ((Event -> {
82+ int cpuSelectedIndex = cpuChoiceBox .getSelectionModel ().getSelectedIndex ();
83+ usersCustomizedComputer .intelConfiguration .setCpuState (cpuSelectedIndex );
84+ usersCustomizedComputer .intelConfiguration .transformProcessorFields ();
85+
86+ processorName = usersCustomizedComputer .intelConfiguration .getProcessorName ();
87+ processorPrice = usersCustomizedComputer .intelConfiguration .getProcessorPrice ();
88+ selectedCpuNameLabel .setText (processorName );
89+ selectedCpuPriceLabel .setText (setFieldToString (processorPrice ));
90+ updateLabels ();
91+ }));
92+
93+ // Memory Choice
94+
95+
96+ // Storage Choice
97+
98+
99+ // Graphics Choice
100+
101+
102+ // Optics Choice
103+
104+
105+ // MS Office Student
106+
107+
108+ // MS Office Business
109+
110+
111+ // Accounting Software Package
112+
113+
114+ // Graphics Software Package
13115 }
116+
117+ @ FXML
118+ public void updateLabels () {
119+ cpuNameLabel .setText (processorName );
120+ cpuPriceLabel .setText (setFieldToString (processorPrice ));
121+ memoryNameLabel .setText (memoryName );
122+ memoryPriceLabel .setText (setFieldToString (memoryPrice ));
123+ storageNameLabel .setText (storageSpaceName );
124+ storagePriceLabel .setText (setFieldToString (storageSpacePrice ));
125+ graphicsNameLabel .setText (graphicsName );
126+ graphicsPriceLabel .setText (setFieldToString (graphicsPrice ));
127+ operatingSystemNameLabel .setText (operatingSystemName );
128+ operatingSystemPriceLabel .setText (setFieldToString (operatingSystemPrice ));
129+ opticalDriveNameLabel .setText (opticalDriveName );
130+ opticalDrivePriceLabel .setText (setFieldToString (opticalDrivePrice ));
131+
132+ audioNameLabel .setText (AUDIO_NAME );
133+ speakersNameLabel .setText (SPEAKERS_NAME );
134+ keyboardNameLabel .setText (KEYBOARD_NAME );
135+ mouseNameLabel .setText (MOUSE_NAME );
136+
137+ // additional software labels
138+
139+ // Update Subtotal Price
140+ double subtotalPrice = processorPrice + memoryPrice + storageSpacePrice + graphicsPrice + operatingSystemPrice +
141+ opticalDrivePrice + msStudentPackagePrice + msBusinessPackagePrice + accountingPackagePrice +
142+ graphicsPackagePrice + basePackagePrice ;
143+ subTotalPriceLabel .setText (setFieldToString (subtotalPrice ));
144+ }
145+
146+ /* Fields */
147+ private String processorName ;
148+ private String memoryName ;
149+ private String storageSpaceName ;
150+ private String graphicsName ;
151+ private String operatingSystemName ;
152+ private String opticalDriveName ;
153+ private final String AUDIO_NAME = usersCustomizedComputer .getAUDIO_NAME ();
154+ private final String SPEAKERS_NAME = usersCustomizedComputer .getSPEAKERS_NAME ();
155+ private final String KEYBOARD_NAME = usersCustomizedComputer .getKEYBOARD_NAME ();
156+ private final String MOUSE_NAME = usersCustomizedComputer .getMOUSE_NAME ();
157+
158+ private double processorPrice ;
159+ private double memoryPrice ;
160+ private double storageSpacePrice ;
161+ private double graphicsPrice ;
162+ private double operatingSystemPrice ;
163+ private double opticalDrivePrice ;
164+
165+ private double msStudentPackagePrice ;
166+ private double msBusinessPackagePrice ;
167+ private double accountingPackagePrice ;
168+ private double graphicsPackagePrice ;
169+ private double basePackagePrice ;
170+
171+ // Main Screen
172+ @ FXML
173+ private AnchorPane mainScreen ;
174+
175+ // AMD Screen
176+ @ FXML
177+ private AnchorPane AMDScreen ;
178+
179+ // Intel Screen
180+ @ FXML
181+ private AnchorPane intelScreen ;
182+ @ FXML
183+ private ChoiceBox <Object > cpuChoiceBox ;
184+ @ FXML
185+ private Label selectedCpuNameLabel ;
186+ @ FXML
187+ private Label selectedCpuPriceLabel ;
188+
189+ // Side Panel
190+ @ FXML
191+ private Label cpuNameLabel ;
192+ @ FXML
193+ private Label cpuPriceLabel ;
194+ @ FXML
195+ private Label memoryNameLabel ;
196+ @ FXML
197+ private Label memoryPriceLabel ;
198+ @ FXML
199+ private Label storageNameLabel ;
200+ @ FXML
201+ private Label storagePriceLabel ;
202+ @ FXML
203+ private Label graphicsNameLabel ;
204+ @ FXML
205+ private Label graphicsPriceLabel ;
206+ @ FXML
207+ private Label operatingSystemNameLabel ;
208+ @ FXML
209+ private Label operatingSystemPriceLabel ;
210+ @ FXML
211+ private Label opticalDriveNameLabel ;
212+ @ FXML
213+ private Label opticalDrivePriceLabel ;
214+ @ FXML
215+ private Label audioNameLabel ;
216+ @ FXML
217+ private Label speakersNameLabel ;
218+ @ FXML
219+ private Label keyboardNameLabel ;
220+ @ FXML
221+ private Label mouseNameLabel ;
222+ @ FXML
223+ private Label subTotalPriceLabel ;
14224}
0 commit comments