Skip to content
Snippets Groups Projects
Commit 92f43763 authored by Russell Furnas Kaup's avatar Russell Furnas Kaup
Browse files

DataConverter has objects stored in three different arrays based on

type, all products inherit from Product class for this. XML
serialization needs work and outputing files is not implemented.
parent c5947e9c
Branches
No related tags found
No related merge requests found
......@@ -8,7 +8,8 @@ import com.thoughtworks.xstream.*;
public class DataConverter {
private Customer[] customerArray;
private Venues[] venuesArray;
private Product[] productArray;
public void readPerson() {
String fileName = "data/Person.dat";
......@@ -45,7 +46,7 @@ public class DataConverter {
}
int size = Integer.parseInt(s.nextLine());
Venues[] venuesArray;
venuesArray = new Venues[size];
for(int i=0;i<size;i++){
......@@ -68,8 +69,9 @@ public class DataConverter {
} catch (FileNotFoundException e) {
e.printStackTrace();
}
int size = Integer.parseInt(s.nextLine());
//up top for testing implementation
//instantiation up top for testing implementation
customerArray = new Customer[size];
for(int i=0;i<size;i++){
String customerTemp = s.nextLine();
......@@ -91,7 +93,10 @@ public class DataConverter {
} catch (FileNotFoundException e) {
e.printStackTrace();
}
int size = Integer.parseInt(s.nextLine());
productArray = new Product[size];
for(int i=0;i<size;i++) {
String productTemp = s.nextLine();
String[] parts = productTemp.split(";");
......@@ -101,12 +106,12 @@ public class DataConverter {
if(type.equals("SR")) {
String name = parts[2];
double cost = Double.parseDouble(parts[3]);
new Refreshments(code,type, name, cost);
productArray[i] = new Refreshments(code,type, name, cost);
}
else if(type.equals("SP")) {
String venueCode = parts[2];
double hourlyFee = Double.parseDouble(parts[3]);
new ParkingPass(code,type,venueCode,hourlyFee);
productArray[i] = new ParkingPass(code,type,venueCode,hourlyFee);
}
else if(type.equals("TG")) {
String venueCode = parts[2];
......@@ -114,19 +119,19 @@ public class DataConverter {
String team1 = parts[4];
String team2 = parts[5];
double pricePerUnit = Double.parseDouble(parts[6]);
new GameTicket(code,type,venueCode, dateTime, team1, team2, pricePerUnit);
productArray[i] = new GameTicket(code,type,venueCode, dateTime, team1, team2, pricePerUnit);
}
else if(type.equals("TS")) {
String team = parts[2];
String startDate = parts[3];
String endDate = parts[4];
double cost = Double.parseDouble(parts[5]);
new SeasonPass(code, type, team, startDate,endDate,cost);
productArray[i] = new SeasonPass(code, type, team, startDate,endDate,cost);
}
else if(type.equals("SL")) {
String ticketCode = parts[2];
double licenseFee = Double.parseDouble(parts[3]);
new PSL(code, type, ticketCode, licenseFee);
productArray[i] = new PSL(code, type, ticketCode, licenseFee);
}
......@@ -140,16 +145,17 @@ public class DataConverter {
return xml;
}
private String serializeObjects(Person[] per[]) {
XStream xstream = new XStream();
String xml = null;
return xml;
}
private String serializeObjects() {
//trying to serialize and output files related to products
for(int i=0;i<customerArray.length;i++) {
public static void main(String args[]) {
serializeObjects(readProduct().)
}
return File;
}
public static void main(String args[]) {
serializeObjects();
}
}
package assignment2;
public class GameTicket {
public class GameTicket implements Product {
private String code;
private String type;
......
......@@ -2,7 +2,7 @@ package assignment2;
public class PSL {
public class PSL implements Product {
private String code;
private String type;
......
package assignment2;
public class ParkingPass {
public class ParkingPass implements Product {
private String code;
private String type;
......
package assignment2;
public interface Product {
String code = null;
}
package assignment2;
public class Refreshments {
public class Refreshments implements Product {
private String code;
private String type;
......
package assignment2;
public class SeasonPass {
public class SeasonPass implements Product {
private String code;
private String type;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment