(For students familiar with XML) Suppose a class A's purpose in life is to convert an object of another class B into textual form for storage to a file. Suppose there are 3 parts to objects of class B that we will call "var", "const", and "virtual". Class A will convert these parts into Strings and enclose them in tags of the form <tag kind="var"> and </tag > where the kind indicates the type of part, which for our purposes we will suppose are var, const, and virtual. These parts might also be nested. A well-designed class A will have a method to convert each kind of part of B into a String, and then it will append those strings to finish the conversion. Each method might look like the following:
public String convertVar() { String result = " <tag kind=\"var\" >"; / /...convert rest of var part of B... result += " </tag >"; return result; } public String convertConst() { String result = " <tag kind=\"const\" >"; //...convert rest of const part of B... result += " </tag >"; return result; } public String convertVirtual() { String result = " <tag kind=\"virtual\" >"; //...convert rest of virtual part of B... result += " </tag >"; return result; }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.