I cannot figure out how to do this Will someone please help
I cannot figure out how to do this. Will someone please help me? I created this code last week:
public static void main(String[] args) {
 // List of company assets
 Asset assetList[]=new Asset[7];
 
 //assetList0 Server
 assetList[0]=new Asset();
 assetList[0].setType(\"Server\");
 assetList[0].setId(0);
 assetList[0].setName(\"IBM Blade Center Hs22\");
 assetList[0].setSerial(\"CNU37569\");
 assetList[0].setPid(-1);
 
 //assetList1 Switch
 assetList[1]=new Asset();
 assetList[1].setType(\"Switch\");
 assetList[1].setId(1);
 assetList[1].setName(\"Cisco Catalyst 2960G\");
 assetList[1].setSerial(\"WY752059\");
 assetList[1].setPid(0);
 
 //assetList2 PSU1
 assetList[2]=new Asset();
 assetList[2].setType(\"PSU1\");
 assetList[2].setId(2);
 assetList[2].setName(\"IBM 39Y7408 2900 Watt PSU\");
 assetList[2].setSerial(\"JWI69839\");
 assetList[2].setPid(0);
 
 //assetList3 PSU2
 assetList[3]=new Asset();
 assetList[3].setType(\"PSU2\");
 assetList[3].setId(3);
 assetList[3].setName(\"IBM 39Y7408 2900 Watt PSU\");
 assetList[3].setSerial(\"JWI29849\");
 assetList[3].setPid(0);
 
 //assetList4 NIC1
 assetList[4]=new Asset();
 assetList[4].setType(\"NIC1\");
 assetList[4].setId(4);
 assetList[4].setName(\"Cisco EHWIC-4ESG 4 Port NIC\");
 assetList[4].setSerial(\"LWK76246\");
 assetList[4].setPid(1);
 
 //assetList5 Nic2
 assetList[5]=new Asset();
 assetList[5].setType(\"NIC2\");
 assetList[5].setId(5);
 assetList[5].setName(\"Cisco EHWIC-4ESG 4 Port NIC\");
 assetList[5].setSerial(\"LWK98352\");
 assetList[5].setPid(1);
 
 //assetList6 Nic3
 assetList[6]=new Asset();
 assetList[6].setType(\"NIC3\");
 assetList[6].setId(6);
 assetList[6].setName(\"Cisco EHWIC-4ESG 4 Port NIC\");
 assetList[6].setSerial(\"LWK56209\");
 assetList[6].setPid(1);
 
 for (Asset asset : assetList) {
 System.out.println(asset);
 }
 }
 }
class Asset
 {
 //instance variables of asset
 String type;
 int id;
 String name;
 String serial;
 int pid;
   
 //default constructor
 Asset()
 {
 type=\"\";
 id=0;
 name=\"\";
 serial=\"\";
 pid=0;
 }
//getters & setters
 public void setType(String a)
 {
 type=a;
 }
 public String getType()
 {
 return type;
 }
 
   
   
 public void setId(int id)
 {
 this.id=id;
 }
 public int getId()
 {
 return id;
 }
   
   
   
 public void setName(String n)
 {
 name=n;
 }
 public String getName()
 {
 return name;
 }
   
   
   
 public void setSerial(String s)
 {
 serial=s;
 }
 public String getSerial()
 {
 return serial;
 }
   
   
   
 public void setPid(int pid)
 {
 this.pid=pid;
 }
 public int getPid()
 {
 return pid;
 }
   
   
 //toString() of asset
 @Override
 public String toString()
 {
 return \"\ \  Type: \" + getType() + \" \  ID: \" + getId() + \" \  Name: \" + getName() + \" \  Serial: \" + getSerial() + \" \  PID: \" + getPid() + \" \ \";
 }
 }
Using that same code, I have to do the following:
Following previous assignment (development of the Asset class) you now need to extend it and create a few derivative classes, i.e. a Router, a Switch, a Server, a PSU (Power Supply Unit) etc. Each of those new classes has to be declared as extending the base Asset class and introduce new attributes and methods. For example, you may consider the following skeletons or add something that matches your expectations:
Router
String application; // one from the following list \"Home\", \"Core\", \"Infrastructure\", etc
int numOfNICs; // number of network interfaces
String OS; // operating system. including vendor, version, and other details
boolean hasConsole; // flag that indicates presence of management console
Switch
int numOf_100M; // number of 100Mb ethernet interfaces
int numOf_1G; // number of 1Gb ethernet interfaces
int numOf_10G; // number of 10Gb ethernet interfaces
int numOf_SFP; // number of SFP modules
String OS; // operating system. including vendor, version, and other details
String level; one from the following list \"L2\", \"L3\", \"L4\"
Server
String OS; // same as with the Router
int NumOfNICs; // same as with the Router
boolean isVirtualized; // flag that shows whether or not this server is a Virtual Machine running on some virtualization platform
You may add more types of assets, and more attributes into each asset to make it looking more realistic, but the grading decision will be based on whether or not inheritance is defined correctly. Inheritance should not be considered as only including keyword \"extends\" in the declaration of a class, but mainly as a proper set of methods that have to be either added or overridden. One of such methods would be the constructor, such that constructor of the Router class will be different than constructor of the Switch class, but both should call constructor of the Asset class by using super(); notation. You may also consider adding up getters/setters for the extended set of attributes.
Please also have in mind that a customized version of toString() method is needed for each derivative class in order to be able to \"print\" corresponding objects. Such method is about to return presentation of all valuable class attributes in form of a formatted String object.
Finally, your Driver program also needs to be revised to update the way how different assets are instantiated:
Previously:
Asset A1 = new Asset(\"server\", \"HP Proliant ML350 G6\", \"876245\", ...);
 Asset A2 = new Asset(\"switch\", \"Netgear GS108T\", \"782364\", ...);
After introducing new sub-classes:
Asset A1 = new Server(\"server\", \"HP Proliant ML350 G6\", \"876245\", ...);
 Asset A2 = new Switch(\"switch\", \"Netgear GS108T\", \"782364\", ...);
Despite both forms look alike, the latter is different as each object is now created by a dedicated constructor so a unique set of attributes is being used.
Solution
nothing goes wrong inthis
public static void main(String[] args) {
 // List of company assets
 Asset assetList[]=new Asset[7];
 
 //assetList0 Server
 assetList[0]=new Asset();
 assetList[0].setType(\"Server\");
 assetList[0].setId(0);
 assetList[0].setName(\"IBM Blade Center Hs22\");
 assetList[0].setSerial(\"CNU37569\");
 assetList[0].setPid(-1);
 
 //assetList1 Switch
 assetList[1]=new Asset();
 assetList[1].setType(\"Switch\");
 assetList[1].setId(1);
 assetList[1].setName(\"Cisco Catalyst 2960G\");
 assetList[1].setSerial(\"WY752059\");
 assetList[1].setPid(0);
 
 //assetList2 PSU1
 assetList[2]=new Asset();
 assetList[2].setType(\"PSU1\");
 assetList[2].setId(2);
 assetList[2].setName(\"IBM 39Y7408 2900 Watt PSU\");
 assetList[2].setSerial(\"JWI69839\");
 assetList[2].setPid(0);
 
 //assetList3 PSU2
 assetList[3]=new Asset();
 assetList[3].setType(\"PSU2\");
 assetList[3].setId(3);
 assetList[3].setName(\"IBM 39Y7408 2900 Watt PSU\");
 assetList[3].setSerial(\"JWI29849\");
 assetList[3].setPid(0);
 
 //assetList4 NIC1
 assetList[4]=new Asset();
 assetList[4].setType(\"NIC1\");
 assetList[4].setId(4);
 assetList[4].setName(\"Cisco EHWIC-4ESG 4 Port NIC\");
 assetList[4].setSerial(\"LWK76246\");
 assetList[4].setPid(1);
 
 //assetList5 Nic2
 assetList[5]=new Asset();
 assetList[5].setType(\"NIC2\");
 assetList[5].setId(5);
 assetList[5].setName(\"Cisco EHWIC-4ESG 4 Port NIC\");
 assetList[5].setSerial(\"LWK98352\");
 assetList[5].setPid(1);
 
 //assetList6 Nic3
 assetList[6]=new Asset();
 assetList[6].setType(\"NIC3\");
 assetList[6].setId(6);
 assetList[6].setName(\"Cisco EHWIC-4ESG 4 Port NIC\");
 assetList[6].setSerial(\"LWK56209\");
 assetList[6].setPid(1);
 
 for (Asset asset : assetList) {
 System.out.println(asset);
 }
 }
 }
class Asset
 {
 //instance variables of asset
 String type;
 int id;
 String name;
 String serial;
 int pid;
   
 //default constructor
 Asset()
 {
 type=\"\";
 id=0;
 name=\"\";
 serial=\"\";
 pid=0;
 }
//getters & setters
 public void setType(String a)
 {
 type=a;
 }
 public String getType()
 {
 return type;
 }
 
   
   
 public void setId(int id)
 {
 this.id=id;
 }
 public int getId()
 {
 return id;
 }
   
   
   
 public void setName(String n)
 {
 name=n;
 }
 public String getName()
 {
 return name;
 }
   
   
   
 public void setSerial(String s)
 {
 serial=s;
 }
 public String getSerial()
 {
 return serial;
 }
   
   
   
 public void setPid(int pid)
 {
 this.pid=pid;
 }
 public int getPid()
 {
 return pid;
 }
   
   
 //toString() of asset
 @Override
 public String toString()
 {
 return \"\ \  Type: \" + getType() + \" \  ID: \" + getId() + \" \  Name: \" + getName() + \" \  Serial: \" + getSerial() + \" \  PID: \" + getPid() + \" \ \";
 }
 }
![I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse](/WebImages/44/i-cannot-figure-out-how-to-do-this-will-someone-please-help-1139180-1761610564-0.webp)
![I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse](/WebImages/44/i-cannot-figure-out-how-to-do-this-will-someone-please-help-1139180-1761610564-1.webp)
![I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse](/WebImages/44/i-cannot-figure-out-how-to-do-this-will-someone-please-help-1139180-1761610564-2.webp)
![I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse](/WebImages/44/i-cannot-figure-out-how-to-do-this-will-someone-please-help-1139180-1761610564-3.webp)
![I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse](/WebImages/44/i-cannot-figure-out-how-to-do-this-will-someone-please-help-1139180-1761610564-4.webp)
![I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse I cannot figure out how to do this. Will someone please help me? I created this code last week: public static void main(String[] args) { // List of company asse](/WebImages/44/i-cannot-figure-out-how-to-do-this-will-someone-please-help-1139180-1761610564-5.webp)
