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

Please program in C# Create a class called Artist that contains 4 pieces of info

ID: 3790112 • Letter: P

Question

Please program in C#

Create a class called Artist that contains 4 pieces of information as instance variables: name (datatype string), specialization – i.e., music, pottery, literature, paintings (datatype string), number of art items (datatype int), country of birth (datatype string).

Create a constructor that initializes the 4 instance variables. The Artist class must contain a property for each instance variable with get and set accessors. The property for number should verify that the Artist contributions is greater than zero. If a negative value is passed in, the set accessor should set the Artist’s number to 0.

Create a second class ArtistTest that creates two Artist objects using the constructor that you developed in the Artist class. Display the name, specialization, number of art items, country of birth.

Explanation / Answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chegg
{
// create class Artist
public class Artist
{

public string name { get; set; }
public string specialization { get; set; }
private int number;
public int number_of_art_items
{
get { return number; }
// set accesor check number if its negative set to value 0
set
{
if (value < 0)
{
number = 0;
}
else { number = value; }
}


}
public string country_of_birth { get; set; }

// constructor for initialization all properties
public Artist()
{
name = "";
specialization = "";
number_of_art_items = 0;
country_of_birth = "";
}
}
class ArtistTest
{
// creating two object for Artist
Artist obj1 = new Artist();
Artist obj2 = new Artist();
public void Display()
{
Console.WriteLine("---------:Displying data using obj1:-------");
Console.WriteLine("Name using obj1:",obj1.name);
Console.WriteLine("specialization using obj1:", obj1.specialization);
Console.WriteLine("number of art items using obj1:", obj1.number_of_art_items);
Console.WriteLine("country of birth using obj1", obj1.country_of_birth);

Console.WriteLine("---------:Displying data using obj2:-------");
Console.WriteLine("Name using obj2:", obj2.name);
Console.WriteLine("specialization using obj2:", obj2.specialization);
Console.WriteLine("number of art items using obj2:", obj2.number_of_art_items);
Console.WriteLine("country of birth using obj2", obj2.country_of_birth);
}

}
class Program
{
static void Main(string[] args)
{
// accessig ArtistTest class and calling function display
ArtistTest obj = new ArtistTest();
obj.Display();
// Readkey() is used to hold output on screen untill user press any key
Console.ReadKey();
}
}
}

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