Programming II Lizard: Json Serialization Week04_Lab12 In this exercise you will be persisting objects by json serializa

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Programming II Lizard: Json Serialization Week04_Lab12 In this exercise you will be persisting objects by json serializa

Post by answerhappygod »

Programming Ii Lizard Json Serialization Week04 Lab12 In This Exercise You Will Be Persisting Objects By Json Serializa 1
Programming Ii Lizard Json Serialization Week04 Lab12 In This Exercise You Will Be Persisting Objects By Json Serializa 1 (67.21 KiB) Viewed 41 times
Programming Ii Lizard Json Serialization Week04 Lab12 In This Exercise You Will Be Persisting Objects By Json Serializa 2
Programming Ii Lizard Json Serialization Week04 Lab12 In This Exercise You Will Be Persisting Objects By Json Serializa 2 (76.46 KiB) Viewed 41 times
Programming II Lizard: Json Serialization Week04_Lab12 In this exercise you will be persisting objects by json serialization. We will start by serializing and deserializing a simple object and then we will try the same with a list of objects to and from files. Json is a convenient format for storing or transmitting data. It enables interfacing to different application or to completely different platforms. It is text-based and it is self-describing so humans can verify the information. Changes in the format does not necessarily break the application. It is simple and it does a superb job. You must implement the following specifications exactly. The LizardColor enum This type contains all the possible color that a lizard can have. This type consists of six members. Enum names are more important than the values it represent. e.g. The name Black is more useful than the integer it represents. Since a lizard can be multi-colored, you will need to decorate the enum with the Flags attribute and assign each constant ascending powers of two. LizardColor Enum Constants: Black Blue Brown Green Yellow Gray Red White Pink Programming II Lizard: Json Serialization Week04_Lab12 The Lizard class This class is a simplistic representation of a lizard. There are four public properties, a constructor and two methods. Lizard Class Properties + <property>> Species wstring + <<property>> Quantity www.int + <property» IsDangerous www bool + <property>> Color mi bizardseler Methods + «c# constructor» Lizard() + JoString() : string $ CreateLizards.() : List<Lizard> Description of the members Properties: All the properties have public getter and private setters Species - this string property represent the species of this lizard. Both the getter and the setter are public. Quantity - this int property represents the number of lizards representing this species. Both the getter and the setter are public. IsDangerous - this bool property indicates if this species is dangerous. Both the getter and the setter are public. Color - this LizardColor property represents the color of this lizard. Both the getter and the setter are public. Constructor: public Lizard()- This default constructor is supplied for serialization only.

Programming II Lizard: Json Serialization Week04_Lab12 Method: public override string ToString() - This public method overrides the ToString() method of the object class. It does not take any argument and returns a string representation of the object. static List<Lizard>CreateLizards () - This class method creates and returns a list of lizards. You may copy the statements below to realize this method. new Lizard)(species - "Crested gecko", Quantity - 4, ISDOBARAHA - false, Color Lindhalar.Yellox | Lizanikalar Mita }, new (Species "Spider-man agama", Quantity 3, D-false, Color - Lizendkalamelus | bizand caterised), new Lizard)(species "Leopard gecko", Quantity - 3, }, ISDOMARAH- true, Color Lizardfalanxelles |Lizardfalamēt at th ISDOBARAH&- false, Color - gecko", Quantity = 4, "Bearded dragon", Quantity - 1, "Crested gecko", Quantity dhalawrink }, SDS- true, Color Lizandralar vellox), 4, ISH-false, Color - Lizardratacelick), Lizendatzesliet}, Quantity - 4, LSDJSKĀ - true, Color-Lizcocalar sceso! new Lizard)(species" new and Species ( new and Species new Lizard) ( Species "Argentine tegu", Quantity 4, JDBAARS-true, Color new and Species "Green Thorny-tailed iguana", Lizardcal Black |LizardCodes Blue}, new bard)(species "Thorny devil", Quantity = 4, ISOJOBARAHA- true, Color-Lizendatzensed), new and Species "Casquehead lizard", Quantity - 4, DERANA true, Color Lizenalan Bed), new and Species "Emerald tree monitor", Quantity 4, JSDH false, Color Lascoço), new Lizard Species "Panther chameleon", Quantity - 6, ISARAH-false, Color Lizandsalariscoso ), new Lizard)(species "Veiled chameleon", Quantity 4, SDH- true, Color - Lizanalenecesa), new and Species "Water monitor", Quantity = 4, ISARAH- false, Color - Lizardkalksklas), new Lizard) ( Species "Komodo dragon", Quantity 4, SARAH- true, Color Lizdalam }, new Lizard) ( Species "Green iguana", Quantity 4, 500 false, Color Lizalariéceso), new and Species "Blotched blue-tongue lizard", Quantity = 4, ISDAARHā- true, Color-Lindsalariilocks }, new Lizard) ( Species "Gila monster", Quantity 4, 5 true, Color - LaalamBlack } Programming II Lizard: Json Serialization Week04_Lab12 Test Harness You will need to write code to test serialization and deserialization of a single lizard object and a list of multiple lizards: List<Lizard > lizards = Lizard:CreateLizards(); Console.WriteLine($"Serializing one lizard"); string filename = "one lizardisen": //code to serialize the first lizard in the collection //to get the first lizard use lizards[0] Console.WriteLine($"De-serializing one lizard"); //code to de-serialize the contents of the above file and display the resulting object Console.WriteLine($"Serializing all lizards"); filename="alizards.json": //code to serialize the entire collection of lizards Console.WriteLine($"De-serializing all lizards"); //code to de-serialize the contents of the above file and display the resulting objects
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply