# data[].attributes.attachment_link.readable_text
package application;

import java.util.HashMap;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Ques1 extends Application{
	public static void main(String[] args) throws Exception{
		launch(args);
	}

	@Override
	public void start(Stage stage) throws Exception {
		Label l1 = new Label("Fruit :");
		ComboBox<String> cbb1 = new ComboBox<String>();
		cbb1.getItems().addAll("Manggo","Apple","Berry");
		cbb1.getSelectionModel().selectFirst();
		
		HashMap<String,Double> hm1 = new HashMap<String,Double>();
		hm1.put("Manggo", 2.50);
		hm1.put("Apple", 2.00);
		hm1.put("Berry", 5.00);
		
		Label l2 = new Label("Quantity :");
		TextField tf1 = new TextField();
		
		HBox hb1 = new HBox();
		hb1.getChildren().addAll(l1,cbb1,l2,tf1);
		hb1.setPadding(new Insets(20,20,20,20));
		hb1.setSpacing(5);
		
		
		Label l3 = new Label("Vegetable :");
		ObservableList<String> vege = FXCollections.observableArrayList(
		          "Sugar", "Carrot", "Tomato", "Chicken", "Peanut");
		ListView<String> lv1 = new ListView<String>(vege);
		
		HashMap<String,Double> hm2 = new HashMap<String,Double>();
		hm2.put("Sugar", 2.50);
		hm2.put("Carrot", 3.50);
		hm2.put("Tomato", 5.00);
		hm2.put("Chicken", 12.50);
		hm2.put("Peanut", 15.50);
		
		Text t1 = new Text("\tItem\t\tQuantity\t\tPrice\t\tTotal\t");
		TextArea ta1 = new TextArea();
		
		VBox vb1 = new VBox();
		vb1.getChildren().addAll(l3,lv1);
		vb1.setPadding(new Insets(20,20,20,20));
		vb1.setSpacing(5);
		
		VBox vb2 = new VBox();
		vb2.getChildren().addAll(t1,ta1);
		vb2.setPadding(new Insets(20,20,20,20));
		vb2.setSpacing(5);
		
		HBox hb2 = new HBox();
		hb2.getChildren().addAll(vb1,vb2);
		
		VBox vb3 = new VBox();
		vb3.getChildren().addAll(hb1,hb2);
		
		tf1.setOnKeyPressed(e->{
			if(e.getCode().equals(KeyCode.ENTER)) {
				if(!tf1.getText().isEmpty() && tf1.getText().matches("[0-9]+") && !tf1.getText().matches("0")) {
					char test = tf1.getText().charAt(0);
					if(test!='0') {
						double itemprice = Double.parseDouble(tf1.getText().toString());
						if(hm1.containsKey(cbb1.getValue().toString())) {
							double price = hm1.get(cbb1.getValue().toString());	
							double tot = price*(itemprice);
							ta1.appendText("\t"+cbb1.getValue().toString()+"\t\t"+tf1.getText().toString()+"\t\t"+price+"\t\t"+tot+"\n");
						}
					}
				}
			}
		});
		
		lv1.setOnMouseClicked(e->{
			String items = lv1.getSelectionModel().getSelectedItem().toString();
			if(hm2.containsKey(items)) {
				double price = hm2.get(items);
				double tot = price;
				ta1.appendText("\t"+items+"\t\t"+1+"\t\t"+price+"\t\t"+tot+"\n");
			}
		});
		
		Scene s1 = new Scene(vb3,600,600);
		stage.setScene(s1);
		stage.setTitle("Shopping Cart");
		stage.show();
		
	}
}

# data[].attributes.body
package application;
import java.util.HashMap;
import javafx.application.Application;
import javafx.collections.*;
import javafx.geometry.*;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Q1_T9 extends Application{
public class Item{
String item; int qty;
double price, total;
Item(String i,int q,double p,double t){
item = i;
qty = q;
price = p;
total = t;
}
//get functions are necessary, with correct naming : getXxx
public String getItem(){ return item; }
public int getQty(){ return qty; }
public double getPrice(){ return price; }
public double getTotal(){ return total; }

//set functions required when you want to edit the table..
}

public void start(Stage primaryStage) throws Exception {

BorderPane pane = new BorderPane();

HBox fruit = new HBox();
ObservableList<String> listFruits =
FXCollections.observableArrayList(
"Mango",
"Berry",
"Apple"
);
final ComboBox comboFruit = new ComboBox(listFruits);
fruit.getChildren().add(new Label("Fruit: "));
fruit.getChildren().add(comboFruit);
TextField tfQuantity = new TextField();
tfQuantity.setPrefColumnCount(5);
fruit.getChildren().add(new Label("Quantity: "));
fruit.getChildren().add(tfQuantity);

HBox vegetables = new HBox();

VBox vboxVege = new VBox();
ListView<String> listVegetables = new ListView<String>();
ObservableList<String> observableVegetables =FXCollections.observableArrayList (
"Sugar", "Carrot", "Tomato", "Chicken", "Peanut");
listVegetables.setItems(observableVegetables);
vboxVege.getChildren().add(new Label("Vegetable: "));
vboxVege.getChildren().add(listVegetables);
listVegetables.setPrefWidth(5);
listVegetables.setPrefHeight(150);
vegetables.getChildren().add(vboxVege);

//using TableView
TableView<Item> itemTable = new TableView<Item>();
itemTable.setPrefWidth(350);

//prepare columns (header)
TableColumn itemCol = new TableColumn("Item");
TableColumn qtyCol = new TableColumn("Qty");
TableColumn priceCol = new TableColumn("Price");
TableColumn totalCol = new TableColumn("Total");
itemTable.getColumns().addAll(itemCol,qtyCol,priceCol,totalCol);

//set the data for each column
itemCol.setCellValueFactory(new PropertyValueFactory<>("item"));
qtyCol.setCellValueFactory(new PropertyValueFactory<>("qty"));
priceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
totalCol.setCellValueFactory(new PropertyValueFactory<>("total"));

//assign data to the table
ObservableList<Item> data = FXCollections.observableArrayList();
itemTable.setItems(data);
vegetables.getChildren().add(itemTable);

HashMap<String,Double> priceList = new HashMap<String,Double>();
priceList.put("Apple", 2.00);
priceList.put("Tomato", 5.00);
priceList.put("Chicken", 12.50);
priceList.put("Peanut", 15.50);
priceList.put("Carrot", 3.50);
priceList.put("Sugar", 2.50);
priceList.put("Berry", 5.00);
priceList.put("Mango", 2.50);

tfQuantity.setOnKeyPressed((e)->{
System.out.println("You Pressed " + e.getCode());
if(e.getCode() ==KeyCode.ENTER) {
double total = 0;
double price = 0;

price = priceList.get(comboFruit.getValue().toString());

total = price*Integer.parseInt(tfQuantity.getText());
data.add(new Item(comboFruit.getValue().toString(),Integer.parseInt(tfQuantity.getText()),price,total));
}
});

listVegetables.setOnMouseClicked((e)->{
System.out.println("You Clicked " + e.getClickCount());
if(e.getClickCount() % 2 == 0) {
double total = 0;
double price = 0;
price = priceList.get(listVegetables.getSelectionModel().getSelectedItem());

total = price*1;
data.add(new Item(listVegetables.getSelectionModel().getSelectedItem(),1,price,total));
}
});

fruit.setPadding(new Insets(5,5,5,5));
vboxVege.setPadding(new Insets(5,5,5,5));
vegetables.setPadding(new Insets(5,5,5,5));
pane.setPadding(new Insets(50,50,50,50));
pane.setTop(fruit);
pane.setLeft(vegetables);
Scene scene = new Scene(pane, 500, 500);
primaryStage.setScene(scene);
primaryStage.setTitle("             Shopping Cart");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

# data[].attributes.attachment_link.readable_text
package application;
import java.util.HashMap;
import javafx.application.Application;
import javafx.collections.*;
import javafx.geometry.*;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class ItemList extends Application{
	public class Item{
	    String item; int qty;
	    double price, total;
	    Item(String i,int q,double p,double t){
	        item = i;
	        qty = q;
	        price = p;
	        total = t;
	    }
	    //get functions are necessary, with correct naming : getXxx
	    public String getItem(){ return item; }
	    public int getQty(){ return qty; }
	    public double getPrice(){ return price; }
	    public double getTotal(){ return total; }
	   
	    //set functions required when you want to edit the table..
	}
	   
	public void start(Stage primaryStage) throws Exception {
	  
		BorderPane pane = new BorderPane();
		
		HBox fruit = new HBox();
		ObservableList<String> listFruits = 
			    FXCollections.observableArrayList(
			        "Mango",
			        "Berry",
			        "Apple"
			    );
		final ComboBox comboFruit = new ComboBox(listFruits);
		fruit.getChildren().add(new Label("Fruit: "));
		fruit.getChildren().add(comboFruit);
		TextField tfQuantity = new TextField();
		tfQuantity.setPrefColumnCount(5);
		fruit.getChildren().add(new Label("Quantity: "));
		fruit.getChildren().add(tfQuantity);
		
		HBox vegetables = new HBox();
		
		VBox vboxVege = new VBox();
		ListView<String> listVegetables = new ListView<String>();
		ObservableList<String> observableVegetables =FXCollections.observableArrayList (
		    "Sugar", "Carrot", "Tomato", "Chicken", "Peanut");
		listVegetables.setItems(observableVegetables);
		vboxVege.getChildren().add(new Label("Vegetable: "));
		vboxVege.getChildren().add(listVegetables);
		listVegetables.setPrefWidth(5);
		listVegetables.setPrefHeight(150);
	    vegetables.getChildren().add(vboxVege);
		
		
	    //using TableView
	    TableView<Item> itemTable = new TableView<Item>();
	    itemTable.setPrefWidth(350);
	           
	    //prepare columns (header)
	    TableColumn itemCol = new TableColumn("Item");
	    TableColumn qtyCol = new TableColumn("Qty");
	    TableColumn priceCol = new TableColumn("Price");
	    TableColumn totalCol = new TableColumn("Total");
	    itemTable.getColumns().addAll(itemCol,qtyCol,priceCol,totalCol);
	 
	    //set the data for each column
	    itemCol.setCellValueFactory(new PropertyValueFactory<>("item"));
	    qtyCol.setCellValueFactory(new PropertyValueFactory<>("qty"));
	    priceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
	    totalCol.setCellValueFactory(new PropertyValueFactory<>("total"));
	 
	    //assign data to the table
	    ObservableList<Item> data = FXCollections.observableArrayList();
	    itemTable.setItems(data);
	    vegetables.getChildren().add(itemTable);
	    
	    HashMap<String,Double> priceList = new HashMap<String,Double>();
	    priceList.put("Apple", 2.00);
	    priceList.put("Tomato", 5.00);
	    priceList.put("Chicken", 12.50);
	    priceList.put("Peanut", 15.50);
	    priceList.put("Carrot", 3.50);
	    priceList.put("Sugar", 2.50);
	    priceList.put("Berry", 5.00);
	    priceList.put("Mango", 2.50);
	    
	    tfQuantity.setOnKeyPressed((e)->{
			System.out.println("You Pressed " + e.getCode());
			if(e.getCode() ==KeyCode.ENTER) {
				double total = 0;
				double price = 0;
				
				price = priceList.get(comboFruit.getValue().toString());

				total = price*Integer.parseInt(tfQuantity.getText());
				data.add(new Item(comboFruit.getValue().toString(),Integer.parseInt(tfQuantity.getText()),price,total));
			}
		});
	    
	    listVegetables.setOnMouseClicked((e)->{
			System.out.println("You Clicked " + e.getClickCount());
			if(e.getClickCount() % 2 == 0) {
				double total = 0;
				double price = 0;
				price = priceList.get(listVegetables.getSelectionModel().getSelectedItem());

				total = price*1;
				data.add(new Item(listVegetables.getSelectionModel().getSelectedItem(),1,price,total));
			}
		});
	    
	    
	    
	    fruit.setPadding(new Insets(5,5,5,5));
	    vboxVege.setPadding(new Insets(5,5,5,5));
	    vegetables.setPadding(new Insets(5,5,5,5));
	    pane.setPadding(new Insets(50,50,50,50));
	    pane.setTop(fruit);
	    pane.setLeft(vegetables);
	    Scene scene = new Scene(pane, 500, 500);
	    primaryStage.setScene(scene);
	    primaryStage.setTitle("             Shopping Cart");
	    primaryStage.show();
	}
	public static void main(String[] args) {
		launch(args);
	}
}

# data[].attributes.body
package application;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class T9Q1 extends Application{

public void start(Stage stage) throws Exception{

Label fruitlbl = new Label("Fruits: ");
Label quantitylbl = new Label("Quantity: ");
Label vegetablelbl = new Label("Vegetable: ");

//=====================comboBox=================================
ComboBox fruitCom = new ComboBox();

fruitCom.getItems().add("orange");
fruitCom.getItems().add("grapes");
fruitCom.getItems().add("manggo");
fruitCom.getItems().add("apple");
fruitCom.getItems().add("durian");

TextField quantitytxt = new TextField();

//===================listview==============================
ListView vegetablelist = new ListView();

vegetablelist.getItems().add("Sugar");
vegetablelist.getItems().add("carrot");
vegetablelist.getItems().add("tomato");
vegetablelist.getItems().add("chicken");
vegetablelist.getItems().add("peanut");

TextArea itemArea = new TextArea();

HBox hbox = new HBox(fruitlbl,fruitCom,quantitylbl,quantitytxt);

VBox vbox = new VBox(vegetablelbl,vegetablelist);
HBox hbox2 = new HBox(vbox,itemArea);

GridPane grid = new GridPane();
grid.add(hbox, 0, 0);
grid.add(hbox2, 0, 1);

Scene scene = new Scene(grid, 600, 500);
stage.setScene(scene);
stage.show();

}

public static void main (String [] args) {
launch(args);

}

@Override
public void start(Stage arg0) throws Exception {
// TODO Auto-generated method stub

}

}

# data[].attributes.attachment_link.readable_text
package application;
import java.util.HashMap;
import javafx.application.Application;
import javafx.collections.*;
import javafx.geometry.*;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Q1_T9 extends Application{
	public class Item{
	    String item; int qty;
	    double price, total;
	    Item(String i,int q,double p,double t){
	        item = i;
	        qty = q;
	        price = p;
	        total = t;
	    }
	    //get functions are necessary, with correct naming : getXxx
	    public String getItem(){ return item; }
	    public int getQty(){ return qty; }
	    public double getPrice(){ return price; }
	    public double getTotal(){ return total; }
	   
	    //set functions required when you want to edit the table..
	}
	   
	public void start(Stage primaryStage) throws Exception {
	  
		BorderPane pane = new BorderPane();
		
		HBox fruit = new HBox();
		ObservableList<String> listFruits = 
			    FXCollections.observableArrayList(
			        "Mango",
			        "Berry",
			        "Apple"
			    );
		final ComboBox comboFruit = new ComboBox(listFruits);
		fruit.getChildren().add(new Label("Fruit: "));
		fruit.getChildren().add(comboFruit);
		TextField tfQuantity = new TextField();
		tfQuantity.setPrefColumnCount(5);
		fruit.getChildren().add(new Label("Quantity: "));
		fruit.getChildren().add(tfQuantity);
		
		HBox vegetables = new HBox();
		
		VBox vboxVege = new VBox();
		ListView<String> listVegetables = new ListView<String>();
		ObservableList<String> observableVegetables =FXCollections.observableArrayList (
		    "Sugar", "Carrot", "Tomato", "Chicken", "Peanut");
		listVegetables.setItems(observableVegetables);
		vboxVege.getChildren().add(new Label("Vegetable: "));
		vboxVege.getChildren().add(listVegetables);
		listVegetables.setPrefWidth(5);
		listVegetables.setPrefHeight(150);
	    vegetables.getChildren().add(vboxVege);
		
		
	    //using TableView
	    TableView<Item> itemTable = new TableView<Item>();
	    itemTable.setPrefWidth(350);
	           
	    //prepare columns (header)
	    TableColumn itemCol = new TableColumn("Item");
	    TableColumn qtyCol = new TableColumn("Qty");
	    TableColumn priceCol = new TableColumn("Price");
	    TableColumn totalCol = new TableColumn("Total");
	    itemTable.getColumns().addAll(itemCol,qtyCol,priceCol,totalCol);
	 
	    //set the data for each column
	    itemCol.setCellValueFactory(new PropertyValueFactory<>("item"));
	    qtyCol.setCellValueFactory(new PropertyValueFactory<>("qty"));
	    priceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
	    totalCol.setCellValueFactory(new PropertyValueFactory<>("total"));
	 
	    //assign data to the table
	    ObservableList<Item> data = FXCollections.observableArrayList();
	    itemTable.setItems(data);
	    vegetables.getChildren().add(itemTable);
	    
	    HashMap<String,Double> priceList = new HashMap<String,Double>();
	    priceList.put("Apple", 2.00);
	    priceList.put("Tomato", 5.00);
	    priceList.put("Chicken", 12.50);
	    priceList.put("Peanut", 15.50);
	    priceList.put("Carrot", 3.50);
	    priceList.put("Sugar", 2.50);
	    priceList.put("Berry", 5.00);
	    priceList.put("Mango", 2.50);
	    
	    tfQuantity.setOnKeyPressed((e)->{
			System.out.println("You Pressed " + e.getCode());
			if(e.getCode() ==KeyCode.ENTER) {
				double total = 0;
				double price = 0;
				
				price = priceList.get(comboFruit.getValue().toString());

				total = price*Integer.parseInt(tfQuantity.getText());
				data.add(new Item(comboFruit.getValue().toString(),Integer.parseInt(tfQuantity.getText()),price,total));
			}
		});
	    
	    listVegetables.setOnMouseClicked((e)->{
			System.out.println("You Clicked " + e.getClickCount());
			if(e.getClickCount() % 2 == 0) {
				double total = 0;
				double price = 0;
				price = priceList.get(listVegetables.getSelectionModel().getSelectedItem());

				total = price*1;
				data.add(new Item(listVegetables.getSelectionModel().getSelectedItem(),1,price,total));
			}
		});
	    
	    
	    
	    fruit.setPadding(new Insets(5,5,5,5));
	    vboxVege.setPadding(new Insets(5,5,5,5));
	    vegetables.setPadding(new Insets(5,5,5,5));
	    pane.setPadding(new Insets(50,50,50,50));
	    pane.setTop(fruit);
	    pane.setLeft(vegetables);
	    Scene scene = new Scene(pane, 500, 500);
	    primaryStage.setScene(scene);
	    primaryStage.setTitle("             Shopping Cart");
	    primaryStage.show();
	}
	public static void main(String[] args) {
		launch(args);
	}
}



# data[].attributes.attachment_link.readable_text
package application;

import java.util.HashMap;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class Tutorial9 extends Application {
	public class Item{
    String item; int  qty; double price, total;
    Item(String i,int q,double p,double t){
        item = i;
        qty = q;
        price = p;
        total = t;
    }
    //get functions are necessary, with correct naming : getXxx
    public String getItem(){ return item; }
    public int getQty(){ return qty; }
    public double getPrice(){ return price; }
    public double getTotal(){ return total; }
   
    //set functions required when you want to edit the table..
    public void update(int q,double t) {
    	qty = q;
      total = t;
    }
}
	
	public void start(Stage stage) {
		
		HashMap <String, Double> priceList = new HashMap<String,Double>();
		ObservableList<Item> data = FXCollections.observableArrayList();
	   
		priceList.put("Apple", 2.00);
		priceList.put("Tomato", 5.0);
		priceList.put("Peanut", 15.50);
		priceList.put("Chicken", 12.50);
		priceList.put("Mango", 4.0);
		priceList.put("Carrot", 2.3);
		priceList.put("Sugar", 1.3);
		priceList.put("Chicken", 1.3);
		
		
		VBox masterPane = new VBox();
		masterPane.setPadding(new Insets(10,10,10,10));
		masterPane.setSpacing(20);
		ComboBox cb = new ComboBox();
		cb.getItems().addAll("Apple", "Mango", "Chicken");
		
		ListView veg = new ListView();
		veg.getItems().addAll("Sugar", "Carrot", "Tomato", "Chicken");
		
		TextField tfQ = new TextField();
		
		
		HBox hbox = new HBox();
		hbox.getChildren().addAll(new Label("Fruit"), cb,new Label("Quantity"),  tfQ);
		hbox.setSpacing(10);
		hbox.setAlignment(Pos.CENTER);
		
		HBox vegiMast = new HBox();
		vegiMast.setSpacing(10);
		VBox vegiBox = new VBox();
		vegiBox.setSpacing(10);
		vegiBox.getChildren().addAll(new Label("Vegetable"), veg);
		TableView <Item> table = new TableView<Item>();
		table.setPrefWidth(350);
		TableColumn itemCol = new TableColumn("Item");
		TableColumn quanCol = new TableColumn("Quantity");
		TableColumn pricCol = new TableColumn("Price");
		TableColumn totaCol = new TableColumn("Total");
		table.getColumns().addAll(itemCol, quanCol, pricCol,totaCol);
		table.setItems(data);
    //set the data for each column
    itemCol.setCellValueFactory(new PropertyValueFactory<>("item"));
    quanCol.setCellValueFactory(new PropertyValueFactory<>("qty"));
    pricCol.setCellValueFactory(new PropertyValueFactory<>("price"));
    totaCol.setCellValueFactory(new PropertyValueFactory<>("total"));
		
		
		tfQ.setOnKeyPressed(e->{
			System.out.println(e.getCode());
			if(e.getCode() == KeyCode.ENTER) {
				System.out.println("y");
				String quan = tfQ.getText();
				try {
					int quantity = Integer.parseInt(quan);
					System.out.println(quantity + cb.getValue().toString());
					String item = cb.getValue().toString();
					Double TPrice = quantity * priceList.get(item);
					
					boolean isExist = false;
					for(int x = 0 ; x<data.size();x++) {
						if(data.get(x).getItem().equals(item)) {
							isExist = true;
							quantity += data.get(x).getQty();
							TPrice = quantity * priceList.get(item);
							data.get(x).update(quantity,TPrice);
							table.refresh();
						}
					}
					if(isExist==false) {
						data.add(new Item(item,quantity,priceList.get(item),TPrice));
					}
					//end
				}catch(Exception ex) {
					ex.printStackTrace();
				}
				
				tfQ.clear();
			}
		});
		
		veg.setOnMouseClicked(e->{
			System.out.println(e.getClickCount());
			if(e.getClickCount()==2) {
				String item = veg.getSelectionModel().getSelectedItem().toString();
				boolean isExist = false;
				for(int x = 0 ; x<data.size();x++) {
					if(data.get(x).getItem().equals(item)) {
						
						isExist = true;
						int quantity = (data.get(x).getQty()) + 1;
						Double TPrice = quantity * priceList.get(item);
						data.get(x).update(quantity,TPrice);
						table.refresh();
					}
				}
				if(isExist==false) {
					data.add(new Item(item,1,priceList.get(item),priceList.get(item)));
				}
			}
			

		});
		
		vegiMast.getChildren().addAll(vegiBox,table);
		vegiMast.setAlignment(Pos.CENTER);
		masterPane.getChildren().addAll(hbox,vegiMast);
		
		Scene scene = new Scene(masterPane);  
		stage.setTitle("Tutorial 9"); 
		stage.setScene(scene); 
		stage.show(); 
	}
	
	public static void main(String args[]) {
		launch(args);
	}
}

# data[].attributes.attachment_link.readable_text
package application;

import java.util.HashMap;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Q1 extends Application{
	public class Item{
	    String item; int qty;
	    double price, total;
	    Item(String i,int q,double p,double t){
	        item = i;
	        qty = q;
	        price = p;
	        total = t;
	    }
	    //get functions are necessary, with correct naming : getXxx
	    public String getItem(){ return item; }
	    public int getQty(){ return qty; }
	    public double getPrice(){ return price; }
	    public double getTotal(){ return total; }
	   
	    //set functions required when you want to edit the table..
	}
	   
	public void start(Stage primaryStage) throws Exception {
	  
		BorderPane pane = new BorderPane();
		
		HBox fruit = new HBox();
		ObservableList<String> olFruits = 
			    FXCollections.observableArrayList(
			        "Mango",
			        "Berry",
			        "Apple"
			    );
		final ComboBox cbFruit = new ComboBox(olFruits);
		fruit.getChildren().add(new Label("Fruit: "));
		fruit.getChildren().add(cbFruit);
		TextField tfQuantity = new TextField();
		tfQuantity.setPrefColumnCount(5);
		fruit.getChildren().add(new Label("Quantity: "));
		fruit.getChildren().add(tfQuantity);
		
		//second row
		HBox others = new HBox();
		
		VBox secondRowFirstColumn = new VBox();
		ListView<String> lwVegetables = new ListView<String>();
		ObservableList<String> olVegetables =FXCollections.observableArrayList (
		    "Sugar", "Carrot", "Tomato", "Chicken", "Peanut");
		lwVegetables.setItems(olVegetables);
		secondRowFirstColumn.getChildren().add(new Label("Vegetable: "));
		secondRowFirstColumn.getChildren().add(lwVegetables);
		lwVegetables.setPrefWidth(5);
		lwVegetables.setPrefHeight(150);
		others.getChildren().add(secondRowFirstColumn);
		
		
	    //using TableView
	    TableView<Item> itemTable = new TableView<Item>();
	    itemTable.setPrefWidth(350);
	           
	    //prepare columns (header)
	    TableColumn itemCol = new TableColumn("Item");
	    TableColumn qtyCol = new TableColumn("Qty");
	    TableColumn priceCol = new TableColumn("Price");
	    TableColumn totalCol = new TableColumn("Total");
	    itemTable.getColumns().addAll(itemCol,qtyCol,priceCol,totalCol);
	 
	    //set the data for each column
	    itemCol.setCellValueFactory(new PropertyValueFactory<>("item"));
	    qtyCol.setCellValueFactory(new PropertyValueFactory<>("qty"));
	    priceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
	    totalCol.setCellValueFactory(new PropertyValueFactory<>("total"));
	 
	    //assign data to the table
	    ObservableList<Item> data = FXCollections.observableArrayList();
	    itemTable.setItems(data);
	    others.getChildren().add(itemTable);
	    
	    HashMap<String,Double> priceList = new HashMap<String,Double>();
	    priceList.put("Apple", 2.00);
	    priceList.put("Tomato", 5.00);
	    priceList.put("Chicken", 12.50);
	    priceList.put("Peanut", 15.50);
	    priceList.put("Carrot", 3.50);
	    priceList.put("Sugar", 2.50);
	    priceList.put("Berry", 5.00);
	    priceList.put("Mango", 2.50);
	    
	    tfQuantity.setOnKeyPressed((e)->{
			System.out.println("You Pressed " + e.getCode());
			if(e.getCode() ==KeyCode.ENTER) {
				double total = 0;
				double price = 0;
				
				price = priceList.get(cbFruit.getValue().toString());

				total = price*Integer.parseInt(tfQuantity.getText());
				data.add(new Item(cbFruit.getValue().toString(),Integer.parseInt(tfQuantity.getText()),price,total));
			}
		});
	    
	    lwVegetables.setOnMouseClicked((e)->{
			System.out.println("You Clicked " + e.getClickCount());
			if(e.getClickCount() % 2 == 0) {
				double total = 0;
				double price = 0;
				price = priceList.get(lwVegetables.getSelectionModel().getSelectedItem());

				total = price*1;
				data.add(new Item(lwVegetables.getSelectionModel().getSelectedItem(),1,price,total));
			}
		});
	    
	    
	    
	    fruit.setPadding(new Insets(5,5,5,5));
	    secondRowFirstColumn.setPadding(new Insets(5,5,5,5));
	    others.setPadding(new Insets(5,5,5,5));
	    pane.setPadding(new Insets(50,50,50,50));
	    pane.setTop(fruit);
	    pane.setLeft(others);
	    Scene scene = new Scene(pane, 500, 500);
	    primaryStage.setScene(scene);
	    primaryStage.show();
	}
	public static void main(String[] args) {
		launch(args);
	}
}

# data[].attributes.attachment_link.readable_text
package application;

import java.util.HashMap;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Question1 extends Application{
	
	public class Item{
	    String item; int qty;double price, total;
	    Item(String i,int q,double p,double t){
	        item = i;
	        qty = q;
	        price = p;
	        total = t;
	    }
	    //get functions are necessary, with correct naming : getXxx
	    public String getItem(){ return item; }
	    public int getQty(){ return qty; }
	    public double getPrice(){ return price; }
	    public double getTotal(){ return total; }
	   
	    //set functions required when you want to edit the table..
	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		// TODO Auto-generated method stub
		
		BorderPane mainPane = new BorderPane();
		
		HBox firstRow = new HBox();
		ObservableList<String> olFruits = 
			    FXCollections.observableArrayList(
			        "Mango",
			        "Berry",
			        "Apple"
			    );
		final ComboBox cbFruit = new ComboBox(olFruits);
		firstRow.getChildren().add(new Label("Fruit: "));
		firstRow.getChildren().add(cbFruit);
		TextField tfQuantity = new TextField();
		tfQuantity.setPrefColumnCount(5);
		firstRow.getChildren().add(new Label("Quantity: "));
		firstRow.getChildren().add(tfQuantity);
		
		//second row
		HBox secondRow = new HBox();
		
		VBox secondRowFirstColumn = new VBox();
		ListView<String> lwVegetables = new ListView<String>();
		ObservableList<String> olVegetables =FXCollections.observableArrayList (
		    "Sugar", "Carrot", "Tomato", "Chicken", "Peanut");
		lwVegetables.setItems(olVegetables);
		secondRowFirstColumn.getChildren().add(new Label("Vegetable: "));
		secondRowFirstColumn.getChildren().add(lwVegetables);
		lwVegetables.setPrefWidth(5);
		lwVegetables.setPrefHeight(150);
		secondRow.getChildren().add(secondRowFirstColumn);
		
		
	    //using TableView
	    TableView<Item> itemTable = new TableView<Item>();
	    itemTable.setPrefWidth(350);
	           
	    //prepare columns (header)
	    TableColumn itemCol = new TableColumn("Item");
	    TableColumn qtyCol = new TableColumn("Qty");
	    TableColumn priceCol = new TableColumn("Price");
	    TableColumn totalCol = new TableColumn("Total");
	    itemTable.getColumns().addAll(itemCol,qtyCol,priceCol,totalCol);
	 
	    //set the data for each column
	    itemCol.setCellValueFactory(new PropertyValueFactory<>("item"));
	    qtyCol.setCellValueFactory(new PropertyValueFactory<>("qty"));
	    priceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
	    totalCol.setCellValueFactory(new PropertyValueFactory<>("total"));
	 
	    //assign data to the table
	    ObservableList<Item> data = FXCollections.observableArrayList();
	    itemTable.setItems(data);
	    secondRow.getChildren().add(itemTable);
	    
	    HashMap<String,Double> priceList = new HashMap<String,Double>();
	    priceList.put("Apple", 2.00);
	    priceList.put("Tomato", 5.00);
	    priceList.put("Chicken", 12.50);
	    priceList.put("Peanut", 15.50);
	    priceList.put("Carrot", 3.50);
	    priceList.put("Sugar", 2.50);
	    priceList.put("Berry", 5.00);
	    priceList.put("Mango", 2.50);
	    
	    tfQuantity.setOnKeyPressed((e)->{
			System.out.println("You Pressed " + e.getCode());
			if(e.getCode() ==KeyCode.ENTER) {
				double total = 0;
				double price = 0;
				
				price = priceList.get(cbFruit.getValue().toString());

				total = price*Integer.parseInt(tfQuantity.getText());
				data.add(new Item(cbFruit.getValue().toString(),Integer.parseInt(tfQuantity.getText()),price,total));
			}
		});
	    
	    lwVegetables.setOnMouseClicked((e)->{
			System.out.println("You Clicked " + e.getClickCount());
			if(e.getClickCount() % 2 == 0) {
				double total = 0;
				double price = 0;
				price = priceList.get(lwVegetables.getSelectionModel().getSelectedItem());

				total = price*1;
				data.add(new Item(lwVegetables.getSelectionModel().getSelectedItem(),1,price,total));
			}
		});
	    
	    
	    
	    firstRow.setPadding(new Insets(5,5,5,5));
	    secondRowFirstColumn.setPadding(new Insets(5,5,5,5));
	    secondRow.setPadding(new Insets(5,5,5,5));
	    mainPane.setPadding(new Insets(50,50,50,50));
	    mainPane.setTop(firstRow);
	    mainPane.setLeft(secondRow);
	    Scene scene = new Scene(mainPane, 500, 500);
	    primaryStage.setScene(scene);
	    primaryStage.show();
		
	}
	
	public static void main(String [] args) {
		launch(args);
	}
	
}

# data[].attributes.body
Tutorial 9

https://drive.ooijiyoung.com/index.php/s/jC9ETanX6fqCSSN

# data[].attributes.body
0328218

# data[].attributes.body
Tutorial 5

# data[].attributes.body
Tut.5

# data[].attributes.body
Tutorial 5
https://drive.ooijiyoung.com/index.php/s/Tnttbw65iHgyCRB

# data[].attributes.body
Tut 5

https://docs.google.com/document/d/1tweBkSbMSgehLplG2u7yiEHM8MVC-mPtqvH9SxLimmI/edit?usp=sharing

# data[].attributes.body
0323601

# data[].attributes.body
Chow yee chen 0333533

# data[].attributes.body
0328895

# data[].attributes.body
0324824

# data[].attributes.body
Jack Chin