Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class encapsulating the concept of a corporate name( for example, IBM) a

ID: 3553998 • Letter: W

Question

Write a class encapsulating the concept of a corporate name( for example, IBM) assuming a corporate name has only one attribute : the corporate name itself. Include a constructor, the accessors and mutators, and methods to string and equals. Also include a method returning a potential domain name by adding www. at the beginning and . com at the end of the corporate name ( for instance , if the corporate name is IBM, that method should return (www.ibm.com). Write a client class to test all methods in your class



JAVA

Explanation / Answer

Dear,


Program:

import java.io.*;
import java.util.*;

class company
{
    private String corporateName;
    //default constructor
    public company()
    {
        corporateName =" ";
    }
     //    mutator method
    public void setName(String cname)
    {
        corporateName = cname;
    }
    public String setName()
    {
        return corporateName;
    }
    //accessors method
    public String toString()
    {
        return "Company name:"+corporateName;
    }
   
    public boolean isEquals(company newcomp)
    {
        if(corporateName.equals(newcomp.corporateName))
            return true;
        else
            return false;
    }
    public String getPotentialName()
    {
        return "www."+corporateName.toLowerCase()+ ".com";
    }
}
public class ClientTest   
{
    public static void main(String[] args)
    {
        //create instance of class
        company comp1 = new company();
        company comp2 = new company();
        comp2.setName("INFI");
        comp1.setName("IBM");
        System.out.println(comp1);
        System.out.println("Potential name:"+comp1.getPotentialName());
        System.out.println("Are compies equal:"+ comp1.equals(comp2));
    }
          
}


Output:

Company name:IBM
Potential name:www.ibm.com
Are compies equal:false

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote