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 696873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:06:36+00:00 2026-05-14T03:06:36+00:00

I have a couple questions about creating a object (2 values) and how to

  • 0

I have a couple questions about creating a object (2 values) and how to “call” it.

Initializing the object with:

Tweetal t1, t2, t3, t4, t5, t6;
t1 = new Tweetal();      //a: 0 , b = 0
t2 = new Tweetal(-2);    //a: -2, b = -2
t3 = new Tweetal(5, 17); //a: 5, b = 17
t4 = new Tweetal(t3);    //a:5, b = 17

Console.Write("t1 = " + t1);
Console.Write("\tt2 = " + t2);
Console.Write("\tt3 = " + t3);
Console.Write("\tt4 = " + t4);
Console.WriteLine("\n");
t1 = t1.Som(t2);
t4 = t2.Som(t2);
//......

Now the 2 things i want to do with this object are taking the SUM and the SUMNumber:
Sum: t4 = t2.sum(t3); (this would result in t4: a:3 (-2+5), b: 15(-2+17)
SumNumber: t1 = t3.sum(8) (this would result in t1: a:13 , b:25)

Sum -> parameter for example t3, t2 etc… SumNumber -> parameter 7, 5,… or 2 numbers (5,7) …

Next is my code for the object (in a separate class), but how exactly do i perform the simple sum calculation when i call up for example t2 etc…

public class Tweetal: Object
{
    private int a;
    private int b;

    public Tweetal()
    {
        //???
        //Sum(...,...)
    }
    public Tweetal(int a)
    {
        //???
        //Sum(...,...)
    }
    public Tweetal(int a, int b)
    {
        //???
    }
    public Tweetal(Tweetal //....) // to call upton the object if i request t1, t2, t3,... insteed of a direct number value)
    {
       // ????
    }


    public void Sum(int aValue, int bValue)
    {
        //a = ???
        //b = ???
        //Sum(...,...)
    }

    public void SumNumber(int aValue, int bValue)
    {

    }


    public override string ToString()
    {
        return string.Format("({0}, {1})", a, b);
    }/*ToString*/
}
  • 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-14T03:06:36+00:00Added an answer on May 14, 2026 at 3:06 am

    First create a constructor that initialises the a and b members:

    public Tweetal(int a, int b)
    {
        this.a = a;
        this.b = b;
    }
    

    Then set up A and B accessors, e.g.:

    public int A { 
                     get {return a;} 
                     set {a = value;}
                 }
    
    public int B { 
                     get {return b;} 
                     set {b = value;}
                 }
    

    Then make the sum method return a new Tweetal.

    public Tweetal sum(Tweetal rhs)
    {
        int a = this.a + rhs.A;
        int b = this.b + rhs.B;
        return new Tweetal(a, b);
    }
    

    Finally your sumNumber method

    public Tweetal sumNumber(int newVal)
    {
        int a = newVal + this.a;
        int b = newVal + this.b;
        return new Tweetal(a,b);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of questions about the way I call methods in EL.
So, I have a couple of questions about scala. 1) Would writing a new
I've never used the ConcurrentDictionary object before and have a couple questions about it:
I have couple of questions about AS3 variables handling by AVM/compiler/scope .1. This code
I have a couple questions about exceptions. 1) when you hit a catch block,
I have a couple questions about submitting blue-tooth enabled apps on the iPhone. I
I have a couple of questions about generic wildcards in Java: What is the
I have a couple of questions about Hello World in Clojure: (println Hello, world!)
I am a newbie to WPF and have a couple of questions about WPF
So I've asked a couple of questions about performing joins and have had great

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.