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

  • SEARCH
  • Home
  • 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 5955857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:10:25+00:00 2026-05-22T18:10:25+00:00

int scalar = creature is SpecialCreature ? (creature.IsAwesome ? 700 : 500) : (creature

  • 0
        int scalar = creature is SpecialCreature ? (creature.IsAwesome ? 700 : 500) : (creature is NotSoNormalCreature ? 
            (creature.IsAwesome ? (creature is IGreatCreature ? 450 : 280) : 240) : 
            (creature.IsAwesome ? (creature is IGreatCreature ? 300 : 200) : 160));

how should I write that code to make it more readable?

I thought of just building the ifs, but then I thought how about making some kind of “ConditionFactory”? Would that make any sense, or is it just too intricate for such a simple task?

int scalar;

if (creature is SpecialCreature)
{
    scalar = creature.IsAwesome ? 700 : 500;
}
else if (creature is NotSoNormalCreature)
{
    if (creature.IsAwesome)
    {
        scalar = creature is IGreatCreature ? 450 : 280;
    }
    else
    {
        scalar = 240;
    }
}
else
{
    if (creature.IsAwesome)
    {
        scalar = creature is IGreatCreature ? 300 : 200;
    }
    else
    {
        scalar = 160;
    }
}
  • 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-22T18:10:26+00:00Added an answer on May 22, 2026 at 6:10 pm

    Not sure entirely what you’re going for, but since you are using a base type inheritance chain, you might elect to do something like

    interface ICreature
    {
        bool IsAwesome { get; set; }
        int GetScalar();
    }
    
    abstract class Creature : ICreature
    {
        public bool IsAwesome { get; set; }
        public virtual int GetScalar()
        {
            return 160;
        }
    }
    
    class SpecialCreature : Creature
    {
        public override int GetScalar()
        {
            return this.IsAwesome ? 700 : 500;
        }
    }
    
    class NotSoNormalCreature : Creature
    {
        public override int GetScalar()
        {
            return this.IsAwesome ? 450 : 280;
        }
    }
    
    // more ICreatures...
    

    Which would allow you to have the creature implement its own logic for determining the scalar, and your consuming code can lose the complication of caring.

    ICreature creature = GetCreatureFromSomewhere();
    int scalar = creature.GetScalar();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable table: DECLARE @A_Table TABLE(ID INT, att1 VARCHAR(100), att2 nvarchar(200)) I
Scalar types as we know are: int, char, float, etc. But pointers are also
I'm getting a compile error conversion from 'int*' to non-scalar type 'foo< int>' requested
Using Scala's command line REPL: def foo(x: Int): Unit = {} def foo(x: String):
scala> val l = List((1,2), (2,3)) l: List[(Int, Int)] = List((1,2), (2,3)) I can
scala> val m = Map(1 -> 2) m: scala.collection.immutable.Map[Int,Int] = Map(1 -> 2) scala>
int x = n / 3; // <-- make this faster // for instance
int x; printf(hello %n World\n, &x); printf(%d\n, x);
int[] mylist = { 2, 4, 5 }; IEnumerable<int> list1 = mylist; list1.ToList().Add(1); //
int n = 5; for(int i = 0;i!=n;i++)//condition != { //executing 5times } int

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.