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: 3790502 • 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.IO;
using System;
class Artist {
private string name;
private string specialization ;
private int numberOfArtItems;
private string countryBirth;
  
public Artist(){
  
}
public Artist(string n,string s, int a, string c ){
name = n;
specialization = s;
numberOfArtItems = a;
countryBirth = c;
}
public void setName(string n){
name = n;
}
public void setSpecialization(string s){
specialization = s;
}
public void setNumberOfArtItems(int n){
numberOfArtItems = n;
}
public void setCountryBirth(string c){
countryBirth = c;
}
public string getName(){
return name;
}
public string getSpecialization(){
return specialization;
}
public int getNumberOfArtItems(){
return numberOfArtItems;
}
public string getCountryBirth(){
return countryBirth;
}
}
class ArtistTest
{
static void Main()
{
Artist a1 = new Artist("Suresh", "MCA", 3, "INDIA");
Artist a2 = new Artist("Dae", "MTECH", 10, "US");
Console.WriteLine("Artist1 Details. Name: "+a1.getName()+" Specialization: "+a1.getSpecialization()+" NumberOfArtItems: "+a1.getNumberOfArtItems()+" CountryBirth: "+a1.getCountryBirth());
Console.WriteLine("Artist2 Details. Name: "+a2.getName()+" Specialization: "+a2.getSpecialization()+" NumberOfArtItems: "+a2.getNumberOfArtItems()+" CountryBirth: "+a2.getCountryBirth());
}
}

Output:

sh-4.3$ mcs *.cs -out:main.exe                                                                                                                                                                                                                                         

sh-4.3$ mono main.exe                                                                                                                                                                                                                                                  

Artist1 Details.                                                                                                                                                                                                                                                       

Name: Suresh Specialization: MCA NumberOfArtItems: 3 CountryBirth: INDIA                                                                                                                                                                                               

Artist2 Details.                                                                                                                                                                                                                                                       

Name: Dae Specialization: MTECH NumberOfArtItems: 10 CountryBirth: US

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