object

Search key and return value in nested object

北慕城南 提交于 2019-12-31 05:48:07
问题 Lets say my object looks like the below. Its a mix of different arrays and parents, no hierarchical order. e.g. "person": { "id": 12345, "name": "John Doe", "emergencyContacts": [ { "name": "Jane Doe", "phone": "888-555-1212", "relationship": "spouse", "moreDetails": { "id": 12345, "phones": {}, "home": "800-123-4567", "mobile": "877-123-1234" } }, { "name": "Justin Doe", "phone": "877-123-1212", "relationship": "parent", "mobile": "877-123-1234" } ], "workContacts": [ { "name": "Jane Doe",

objects classes and arrays - why is it returning 'null' ? [java]

試著忘記壹切 提交于 2019-12-31 05:36:13
问题 I wrote a small class that creates a report object containing 3 arrays. At creation of the object these arrays are initialised with values. However when i test the class to see for example what's in the departments array, it prints out that the array elements are null. why? class Report { // declare instance variables (arrays) public String[] departments = new String[4] ; public double[] grossTotals = new double[4] ; public double[] taxTotals = new double[4] ; // constructor public Report(){

constructor not accepting my information

。_饼干妹妹 提交于 2019-12-31 05:30:10
问题 so the constuctor is saying ) expected, error not a statement and ; expected Person num1, num2, num3; num1=new Person(Allison, 6600 Crescent Ave, 32, 9024231421); num2=new Person(George, 5251 Lakewood St, 24, 9024489216); num3=new Person(Michael, 2429 Inglis St, 56, 9024212345); object class public Person() { } //constructor allows programmer to define variable values in demo class public Person(String nm, String adr, int ag, long phn) { name=nm; address=adr; age=ag; phoneNumber=phn; } 回答1:

Add property to each object in the array

若如初见. 提交于 2019-12-31 05:26:06
问题 I'm trying to add a property to each object in the array: var capitals = [{ country: "What's the capital of Ecuador?", choices: ["Quito", "Caracas", "Panama", "Loja"], corAnswer: 0 }, { country: "What is the capital of China?", choices: ["Shanghai", "Beijing", "Ghangzou", "Hong Kong"], corAnswer: 0 }]; Should become: var capitals = [{ country: "What's the capital of Ecuador?", choices: ["Quito", "Caracas", "Panama", "Loja"], corAnswer: 0, global: true }, { country: "What is the capital of

Iterative conditional removal of object property using 'for..in' and 'if' [duplicate]

依然范特西╮ 提交于 2019-12-31 05:16:10
问题 This question already has answers here : Dynamically access object property using variable (13 answers) Closed 2 years ago . function removeNumbersLargerThan(num, obj) { for (var key in obj) { if (!isNaN(obj[key]) && obj[key] > num) { delete obj.key; } } return obj; } var obj = { a: 8, b: 2, c: 'montana' } removeNumbersLargerThan(5, obj); console.log(obj); // Should be {b: 2, c: 'montana'} The function should remove any property that meets the 'if' condition inside the 'for' loop, but it

Only the last Object is added to the ArrayList

℡╲_俬逩灬. 提交于 2019-12-31 05:14:21
问题 I created a user defined data type and read data from a file. Here are the codes: Student Class: package system.data; public class Student { private String firstName; private String lastName; private String regNumber; private int coursework1Marks; private int coursework2Marks; private int finalExamMarks; private double totalMarks; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return

verify creation of database objects such as triggers, procedures , permissions

一世执手 提交于 2019-12-31 05:07:09
问题 I am creating triggers & procedures on a table from a winform application which uses sql server 2005 express. I want that when the user clicks the create trigger/procedure button, then it creates both the objects & displays on a new Form that triggers & procedures are created with the names and tables on which they are created. I mean that how do i verify that the objects are created. i want to verify and show it to the user that the objects are created on the so and so table. 回答1: After your

How to blit an image, in python, inside the area of a specific image?

白昼怎懂夜的黑 提交于 2019-12-31 05:04:12
问题 I'm making a game and I need to blit my objects inside the area of a specific image. I don't want to need my surface to blit these images. Is it possible? (I'm using pygame) 回答1: It would be better in the future if you would explain what you are trying to do a bit better since it would give you more answers :) From what I have understood you want to blit an image onto another image: For this code to work the following premises are set: The folder which contains the program also contains the

unwanted object property changed when changing another object property c#

人走茶凉 提交于 2019-12-31 04:58:07
问题 from what i understand in other posts i know that my objects use same place in memory but how to separate these objects? i tried to use new but it didn't work or i didn't used it correctly. Note that i didnt paste setter and getter here. class Supermarket { List<Product> _products = new List<Product>{ }; List<Customer> _customers = new List<Customer>{ }; } class Customer { List<Product> _purchased= new List<Product>{ }; } class Product { string _id; string _name; DateTime _expireDate; int

Changing arrays using map in javascript

∥☆過路亽.° 提交于 2019-12-31 04:48:18
问题 This is my json object: { "id": 2, "service": "mobile", "min": "20", "per": "10", "tax": "1", "categoryservices": [ { "category": { "id": 1, "name": "laptop" } }, { "category": { "id": 2, "name": "software" } } ] } I want my output like this: { "id": 2, "service": "mobile", "min": "20", "per": "10", "tax": "1", "cats": [1,2] // this 1 and 2 is coming from categoriesservices array inside the category object i have id } How to do this using map function? I am new to javascript, which is good