Skip to content

Commit

Permalink
Auction Incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBrave committed Jul 24, 2020
1 parent d5c8a98 commit c8e2111
Show file tree
Hide file tree
Showing 12 changed files with 423 additions and 114 deletions.
19 changes: 17 additions & 2 deletions src/main/java/Controller/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,24 @@ else if (command.startsWith("show balance")) {
this.deleteSupporter(command);
} else if (command.startsWith("get online users+")) {
getOnlineUsers();
} else if (command.startsWith("getting all products")) {
this.getAllProducts(command);
}

}

private void getAllProducts(String command) {
String answer = "";
for (Product product : Storage.getAllProducts()) {
if (product.getSalesmanIDs().contains(command.split("\\+")[1])) {
if (product.getRemainderForSalesman(command.split("\\+")[1]) > 0) {
answer += product.getProductID() + "\n";
}
}
}
setAnswer(answer);
}

public void takeActionNotSecure(String command) throws ParseException {
Matcher matcher;
if ((matcher = getMatcher("login\\+(\\w+)\\+(\\w+)", command)).find()) {
Expand Down Expand Up @@ -444,7 +458,7 @@ public void takeActionNotSecure(String command) throws ParseException {
this.addProductPicturePath(command);
} else if (command.startsWith("get product picture path+")) {
this.getProfilePicturePath(command);
}else if (command.startsWith("show products+")) {
} else if (command.startsWith("show products+")) {
this.showProducts(command);
} else if (command.startsWith("show my products+")) {
this.showMyProducts(command);
Expand Down Expand Up @@ -492,7 +506,7 @@ public void takeActionNotSecure(String command) throws ParseException {
this.viewSale(command);
} else if (command.startsWith("show sales")) {
this.showSales(command);
} else if (command.startsWith("what is comment product ID+")) {
} else if (command.startsWith("what is comment product ID+")) {
this.getCommentProductID(command);
} else if (command.startsWith("comment product+")) {
this.commentProduct(command);
Expand Down Expand Up @@ -1249,6 +1263,7 @@ private void showMyProducts(String command) {
}

private void showProducts(String command) {
System.out.println(command);
ArrayList<Object> filters;
filters = getFilters(command);
String[] input = command.split("\\+");
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/GUI/Auction/AllAuctions.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="GUI.Auction.AllAuctions"
prefHeight="400.0" prefWidth="600.0">

</AnchorPane>
4 changes: 4 additions & 0 deletions src/main/java/GUI/Auction/AllAuctionsController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package GUI.Auction;

public class AllAuctionsController {
}
110 changes: 102 additions & 8 deletions src/main/java/GUI/Auction/AuctionBet.fxml
Original file line number Diff line number Diff line change
@@ -1,14 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>

<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="GUI.Auction.AuctionBet"
prefHeight="400.0" prefWidth="600.0">

<AnchorPane prefHeight="566.0" prefWidth="869.0" xmlns="http://javafx.com/javafx/10.0.2-internal"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="GUI.Auction.AuctionBetController">
<children>
<ScrollPane layoutX="14.0" layoutY="12.0">
<content>
<VBox fx:id="vBox" prefHeight="542.0" prefWidth="422.0"/>
</content>
</ScrollPane>
<TextField fx:id="maxBet" editable="false" layoutX="638.0" layoutY="81.0"/>
<Label layoutX="502.0" layoutY="85.0" text="Maximum Wage:"/>
<Label layoutX="502.0" layoutY="182.0" text="Enter Your Bet: "/>
<TextField fx:id="myBet" layoutX="638.0" layoutY="178.0"/>
<Button layoutX="547.0" layoutY="246.0" mnemonicParsing="false" onAction="#apply" text="Apply"/>
<Button layoutX="616.0" layoutY="246.0" mnemonicParsing="false" onAction="#back" text="Back"/>
<AnchorPane layoutX="451.0" layoutY="296.0" prefHeight="163.0" prefWidth="412.0">
<children>
<GridPane layoutX="39.0" layoutY="55.0" prefHeight="163.2" prefWidth="412.0"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="201.0" minWidth="10.0" prefWidth="144.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="330.0" minWidth="10.0" prefWidth="268.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<AnchorPane prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: #244949;">
<children>
<ImageView fitHeight="125.0" fitWidth="144.0" layoutX="17.0" layoutY="19.0"
pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@resources/Timer.jpg"/>
</image>
</ImageView>
</children>
</AnchorPane>
<StackPane prefHeight="150.0" prefWidth="200.0" style="-fx-background-color: #9AABAB;"
GridPane.columnIndex="1">
<children>
<GridPane prefHeight="146.0" prefWidth="268.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="128.4" minHeight="10.0" prefHeight="121.4"
vgrow="SOMETIMES"/>
<RowConstraints maxHeight="76.4" minHeight="10.0"
prefHeight="41.400000000000006" vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<GridPane prefHeight="165.0" prefWidth="268.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="129.0" minWidth="10.0"
prefWidth="111.0"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="157.0" minWidth="10.0"
prefWidth="157.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<children>
<Label text="Hours" textFill="#244949" GridPane.halignment="CENTER">
<font>
<Font name="System Bold" size="12.0"/>
</font>
</Label>
<Label layoutX="51.0" layoutY="21.0" text="Minutes" textFill="#244949"
GridPane.halignment="CENTER" GridPane.rowIndex="1">
<font>
<Font name="System Bold" size="12.0"/>
</font>
</Label>
<Label layoutX="51.0" layoutY="62.0" text="Seconds" textFill="#244949"
GridPane.halignment="CENTER" GridPane.rowIndex="2">
<font>
<Font name="System Bold" size="12.0"/>
</font>
</Label>
<Label fx:id="hour" prefWidth="28.0" text="Label"
GridPane.columnIndex="1" GridPane.halignment="CENTER"/>
<Label fx:id="minute" layoutX="186.0" layoutY="21.0" text="Label"
GridPane.columnIndex="1" GridPane.halignment="CENTER"
GridPane.rowIndex="1"/>
<Label fx:id="second" layoutX="186.0" layoutY="21.0" text="Label"
GridPane.columnIndex="1" GridPane.halignment="CENTER"
GridPane.rowIndex="2"/>
</children>
</GridPane>
</children>
</GridPane>
</children>
</StackPane>
</children>
</GridPane>
</children>
</AnchorPane>
</children>
</AnchorPane>
64 changes: 64 additions & 0 deletions src/main/java/GUI/Auction/AuctionBetController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package GUI.Auction;

import GUI.MenuHandler;
import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

import java.io.IOException;

public class AuctionBetController {
public TextField maxBet;
public TextField myBet;
public Label hour;
public Label minute;
public Label second;
public VBox vBox;

public void apply(ActionEvent actionEvent) {
}

public void back(ActionEvent actionEvent) throws IOException {
MenuHandler.getStage().setScene(new Scene(FXMLLoader.load(getClass().getResource("/GUI/ProductScene/ProductScene.fxml"))));
}

private void load() throws IOException {
MenuHandler.getConnector().clientToServer("get certain auction+" + MenuHandler.getCurrentAuction() + "+" + MenuHandler.getUsername());
String serverAnswer = MenuHandler.getConnector().serverToClient();
for (String s : serverAnswer.split("\n")) {
String username = s.split("\\+")[0];
String money = s.split("\\+")[1];
HBox hBox = new HBox();
Label userLabel = new Label(username);
Label moneyLabel = new Label(money);
hBox.getChildren().add(userLabel);
hBox.getChildren().add(moneyLabel);
vBox.getChildren().add(hBox);
}
MenuHandler.getConnector().clientToServer("get auction time+" + MenuHandler.getCurrentAuction());
String time = MenuHandler.getConnector().serverToClient();
}

public void initialize() {
Thread thread;
thread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
load();
wait(900);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
});
thread.run();
}
}
109 changes: 50 additions & 59 deletions src/main/java/GUI/Auction/AuctionChat.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,63 +7,54 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>

<AnchorPane prefHeight="674.0" prefWidth="656.0" style="-fx-background-color: yellow;" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="GUI.Auction.AuctionChat">
<children>
<ScrollPane layoutX="63.0" layoutY="111.0" prefHeight="475.0" prefWidth="535.0">
<content>
<VBox fx:id="VBOX" prefHeight="472.0" prefWidth="531.0">
<children>
<Label alignment="CENTER" layoutX="177.0" layoutY="10.0">
<font>
<Font size="16.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="177.0" layoutY="35.0" prefHeight="30.0" prefWidth="243.0" text="Hossein: this is bullshit">
<font>
<Font size="20.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="10.0" layoutY="35.0" prefHeight="27.0" prefWidth="219.0">
<font>
<Font size="20.0" />
</font>
</Label>
<Label alignment="CENTER" layoutX="10.0" layoutY="65.0" prefHeight="30.0" prefWidth="307.0" text=" Sarah: well it's that bad anyway">
<font>
<Font size="20.0" />
</font>
</Label>
</children></VBox>
</content>
<effect>
<SepiaTone level="0.87" />
</effect>
</ScrollPane>
<Label layoutX="257.0" layoutY="25.0" prefHeight="45.0" prefWidth="141.0" text="Chat Room" textFill="#fc2727">
<font>
<Font name="Agency FB Bold" size="37.0" />
</font>
</Label>
<ImageView fx:id="backIcon" fitHeight="53.0" fitWidth="49.0" layoutX="588.0" layoutY="23.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@resources/columns-android-application-software-png-favpng-wFDL9gA90YH4weKLuFNwg0CiE_t.jpg" />
</image>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</ImageView>
<TextField layoutX="63.0" layoutY="604.0" prefHeight="39.0" prefWidth="476.0" promptText="Enter Your Message Here">
<font>
<Font name="System Italic" size="18.0" />
</font>
</TextField>
<ImageView fx:id="sendMessage" fitHeight="39.0" fitWidth="42.0" layoutX="556.0" layoutY="604.0" opacity="0.9" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@resources/113-1130161_send-icon-png-sending-message-image-clip.png" />
</image>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</ImageView>
</children>
<AnchorPane prefHeight="674.0" prefWidth="656.0" style="-fx-background-color: yellow;"
xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="GUI.Auction.AuctionChatController">
<children>
<ScrollPane layoutX="63.0" layoutY="111.0" prefHeight="475.0" prefWidth="535.0">
<content>
<VBox fx:id="VBOX" prefHeight="472.0" prefWidth="531.0">
<children>
<Label alignment="CENTER" layoutX="177.0" layoutY="10.0">
<font>
<Font size="16.0"/>
</font>
</Label>
</children>
</VBox>
</content>
<effect>
<SepiaTone level="0.87"/>
</effect>
</ScrollPane>
<Label layoutX="257.0" layoutY="25.0" prefHeight="45.0" prefWidth="141.0" text="Chat Room" textFill="#fc2727">
<font>
<Font name="Agency FB Bold" size="37.0"/>
</font>
</Label>
<ImageView fx:id="backIcon" fitHeight="53.0" fitWidth="49.0" layoutX="588.0" layoutY="23.0"
onMousePressed="#back" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@resources/columns-android-application-software-png-favpng-wFDL9gA90YH4weKLuFNwg0CiE_t.jpg"/>
</image>
<cursor>
<Cursor fx:constant="HAND"/>
</cursor>
</ImageView>
<TextField fx:id="message" layoutX="63.0" layoutY="604.0" prefHeight="39.0" prefWidth="476.0"
promptText="Enter Your Message Here">
<font>
<Font name="System Italic" size="18.0"/>
</font>
</TextField>
<ImageView fx:id="sendMessage" fitHeight="39.0" fitWidth="42.0" layoutX="556.0" layoutY="604.0"
onMousePressed="#sendMessage" opacity="0.9" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@resources/113-1130161_send-icon-png-sending-message-image-clip.png"/>
</image>
<cursor>
<Cursor fx:constant="HAND"/>
</cursor>
</ImageView>
</children>
</AnchorPane>
Loading

0 comments on commit c8e2111

Please sign in to comment.