[Solved] Needing help understanding piece of Java code

On your class DVDPlayer you chose to say that a regular DVDPlayer cannot record. So you set it to false. If you want it to record you either change the variable directly, like you did on the class DVDPlayerTestDrive. The boolean canRecord = false is only meant to show you that it is possible to … Read more

[Solved] Need a Python program Singular to Plural [closed]

Just make it so that it appends “s” unless the word ends with “y” or some other exception: def plural(word): wordlist = [] for char in word: wordlist.append(char) if word[len(word)-1] == “y”: wordlist[len(word)-1] = “ies” else: wordlist.append(“s”) word = “” for i in wordlist: word+=i return word print(plural(“STRING”)) solved Need a Python program Singular to … Read more

[Solved] How to retrieve an element inside a Map in Java?

Your ENUM values on the map seem like another map. Therefore I put it like this Map<Enum, Map<String, Object>> However, question is not clear! Here is one possible solution. import java.util.*; public class Main { public static void main(String[] args) { Map<Enum, Map<String, Object>> map = new HashMap<>(); Map<String, Object> value = new HashMap<>(); value.put(“String1”, … Read more

[Solved] How to fix the setter of the fullName property to enable an automatic update for the firstName and lastName properties? [closed]

Your class is basically right (though the setter for fullName isn’t handling anything other than fullNameArr.count == 3). class Person { var firstName: String var lastName: String var fullName: String { get { “\(firstName) \(lastName)” } set { let names = newValue.components(separatedBy: ” “) lastName = names.last ?? “” firstName = names.dropLast().joined(separator: ” “) } … Read more

[Solved] why is this program taking integer and alpha numeric inputs and printing them? does std::string in c++ take integer values as well? [closed]

why is this program taking integer and alpha numeric inputs and printing them? does std::string in c++ take integer values as well? [closed] solved why is this program taking integer and alpha numeric inputs and printing them? does std::string in c++ take integer values as well? [closed]

[Solved] Extended for loop in C++

When for (int ai : a) std::cout << ai; is used for array – int a[20]; it can be substituted with for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) std::cout << a[i]; or with for (int *ai = a; ai < a + (sizeof(a)/sizeof(*a)); ai++) std::cout << *ai; But to work with … Read more

[Solved] Python split a string at an underscore

Assuming that you have a string with multiple instances of the same delimiter and you want to split at the nth delimiter, ignoring the others. Here’s a solution using just split and join, without complicated regular expressions. This might be a bit easier to adapt to other delimiters and particularly other values of n. def … Read more

[Solved] In what circumstances does getcwd() return NULL?

Its documentation states: ERRORS The getcwd() function shall fail if: [EINVAL] The size argument is 0. [ERANGE] The size argument is greater than 0, but is smaller than the length of the pathname +1. The getcwd() function may fail if: [EACCES] Read or search permission was denied for a component of the pathname. [ENOMEM] Insufficient … Read more