Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 554807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:44:57+00:00 2026-05-13T11:44:57+00:00

I have a list of objects I must set a property based on two

  • 0

I have a list of objects I must set a property based on two criteria the 2D grid looks like this:

Property 2\Property 1   B<80        80<B<100       100<B<120           B>120
A < 100                 None          Red           Orange            Orange
100 < A < 120           None          Red           Orange             Green
120 < A < 140           None          Red           Green              Green
140 < A                 None         Orange         Green              Green

Is there a good way to loop Property 1 and Property 2 to dynamically set the object property? It is a possibility that in the future we add few criteria and I guess that doing multiple ifs isn’t a good solution. I’m trying to avoid redundant code.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:44:57+00:00Added an answer on May 13, 2026 at 11:44 am

    If we could convert the 2 conditions for A and B into a system with a scale of 0-3:
    if A<100 -> Ascale = 0
    else if A<120 -> Ascale = 1
    etc.
    and for B:
    if B<80 -> Bscale = 0
    else if B<100 -> Bscale = 1
    etc.

    Then we could use a 2d array for looking up the correct output response:
    out = arrayname[Ascale][Bscale];

    But I don’t think this saves anything over simply hard-coding it as ifs, when only the possibility of a few extra ones, I think that hard-coding is the best solution for this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of objects I wish to sort based on a field
I have a list of objects and I would like to access the objects
I have a list of objects, each containing an Id, Code and Description. I
I have IQueryable list of objects of type T which I want to transform
I have a list of objects (for the sake of example, let's say 5).
I have a list of objects and I want to reorder them randomly on
I have a list of objects which need to be output 2 items per
I have a list of objects output from ldapsearch as follows: dn: cn=HPOTTER,ou=STUDENTS,ou=HOGWARTS,o=SCHOOL dn:
I have a list of bean objects passed into my JSP page, and one
I have a list of Date objects, and a target Date. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.