Question: Using the attached Java classes (Arcade.java and Pinball.java) as a guide, create a representative JSON string that might be produced upon serialization of an Arcade
- Using the attached Java classes (Arcade.java and Pinball.java) as a guide, create a representative JSON string that might be produced upon serialization of an Arcade object. You are free to populate the Arcade and Pinball object properties with any data you like as long as it is not empty/blank and accurately represents the associated propertys data type (e.g., a numeric data type contains a number).
Arcade.java:
public class Arcade
{
private String name;
private Pinball[] machines;
private int establishmentYear;
public Arcade()
{
this.name = "";
this.establishmentYear = 1900;
this.machines = new Pinball[0];
}
public Arcade(String n, int e, Pinball[] m)
{
name = n;
establishmentYear = e;
machines = m;
}
//setters
public void setName(String name)
{
this.name = name;
}
public void setEstablishmentYear(int year)
{
this.establishmentYear = year;
}
public void setMachines(Pinball[] machines)
{
this.machines = machines;
}
//getters
public String getName()
{
return name;
}
public int getEstablishmentYear()
{
return establishmentYear;
}
public Pinball[] getMachines()
{
return machines;
}
}
Pinball.java:
public class Pinball
{
private String name;
private String manufacturer;
private int yearProduced;
public Pinball()
{
this.name = "";
this.manufacturer = "";
this.yearProduced = 1900;
}
public Pinball(String n, String m, int y)
{
name = n;
manufacturer = m;
yearProduced = y;
}
//setters
public void setName(String name)
{
this.name = name;
}
public void setManufacturer(String manufacturer)
{
this.manufacturer = manufacturer;
}
public void setYearProduced(int year)
{
this.yearProduced = year;
}
//getters
public String getName()
{
return name;
}
public String getManufacturer()
{
return manufacturer;
}
public int getYearProduced()
{
return yearProduced;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
