mirror of
https://github.com/danog/WarehouseLibrary.git
synced 2024-12-02 09:18:03 +01:00
Fixes
This commit is contained in:
parent
a7de077ff7
commit
61ad7d089a
@ -18,7 +18,7 @@ package Main;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Studente
|
||||
* @author Daniil Gentili
|
||||
*/
|
||||
public class Cart extends Container {
|
||||
public Cart(String input) {
|
||||
|
@ -19,8 +19,6 @@ package Main;
|
||||
import Payloads.RequestPayload;
|
||||
import Payloads.ResponsePayload;
|
||||
import Payloads.ServerException;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
@ -30,9 +28,9 @@ import java.net.Socket;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
* @author Daniil Gentili
|
||||
*/
|
||||
public class Client implements ActionListener {
|
||||
public class Client {
|
||||
private BufferedWriter out;
|
||||
private BufferedReader in;
|
||||
|
||||
@ -70,7 +68,6 @@ public class Client implements ActionListener {
|
||||
}
|
||||
|
||||
public void commit() throws IOException, ServerException {
|
||||
|
||||
RequestPayload request = new RequestPayload("POST", "/", cart.getPayload());
|
||||
request.shouldKeepAlive(true);
|
||||
request.write(out);
|
||||
@ -80,21 +77,7 @@ public class Client implements ActionListener {
|
||||
if (response.getResponseCode() != 200) {
|
||||
throw new ServerException(response);
|
||||
}
|
||||
warehouse = new Warehouse(response.getPayload());
|
||||
cart = new Cart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.out.println(e.paramString());
|
||||
/* if (e.getText().equals("Buy")) {
|
||||
try {
|
||||
this.addToCart(Integer.parseInt(e.getActionCommand()));
|
||||
} catch (ClientException ex) {
|
||||
Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
*/
|
||||
this.warehouse.rebuild(response.getPayload());
|
||||
this.cart.rebuild();
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ package Main;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
* @author Daniil Gentili
|
||||
*/
|
||||
public class ClientException extends Exception {
|
||||
|
||||
|
@ -20,7 +20,7 @@ import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
* @author Daniil Gentili
|
||||
*/
|
||||
public abstract class Container
|
||||
{
|
||||
@ -32,6 +32,17 @@ public abstract class Container
|
||||
Constructors
|
||||
*/
|
||||
public Container(String response) {
|
||||
rebuild(response);
|
||||
}
|
||||
public Container() {
|
||||
rebuild();
|
||||
}
|
||||
|
||||
public void rebuild() {
|
||||
this.products.clear();
|
||||
}
|
||||
public void rebuild(String response) {
|
||||
this.products.clear();
|
||||
String[] split;
|
||||
for (String line: response.split("\n")) {
|
||||
split = line.split(";");
|
||||
@ -48,11 +59,6 @@ public abstract class Container
|
||||
);
|
||||
}
|
||||
}
|
||||
public Container() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the string payload of the container
|
||||
* @return The string payload
|
||||
|
@ -18,7 +18,7 @@ package Main;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Studente
|
||||
* @author Daniil Gentili
|
||||
*/
|
||||
public class Product {
|
||||
private Double price;
|
||||
|
@ -19,7 +19,7 @@ package Main;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
* @author Daniil Gentili
|
||||
*/
|
||||
public class ProductCollection {
|
||||
private final Product product;
|
||||
|
@ -18,7 +18,7 @@ package Main;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
* @author Daniil Gentili
|
||||
*/
|
||||
public class Warehouse extends Container {
|
||||
public Warehouse(String input) {
|
||||
|
Loading…
Reference in New Issue
Block a user