using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Buku
{
class Program
{
struct book
{
private string title;
private string authors;
private string subject;
private int book_id;
public void getValues(string t, string a, string s, int id)
{
title = t;
authors = a;
subject = s;
book_id = id;
}
public void display()
{
Console.WriteLine("Buku yang dimaksud memiliki spesifikasi seperti berikut : ");
Console.WriteLine("Title = {0}", title);
Console.WriteLine("Authors = {0}", authors);
Console.WriteLine("Subject = {0}", subject);
Console.WriteLine("Book ID = {0}", book_id);
}
};
public class testStructure
{
static void Main(string[] args)
{
book Book1 = new book();
book Book2 = new book();
Book1.getValues("C Programming", "Nuha Ali", "C Programming Tutorial", 6495407);
Book2.getValues("Telecom Billing", "Zahra Ali", "Telecom Billing Tutorial", 6495700);
Console.WriteLine("Buku 1 ID = 6495407");
Console.WriteLine("Buku 2 ID = 6495700 \n");
Console.WriteLine("Masukkan ID : ");
int a = int.Parse(Console.ReadLine());
if (a == 6495407)
{
Book1.display();
}
if (a == 6495700)
{
Book2.display();
}
Console.ReadKey();
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Buku
{
class Program
{
struct book
{
private string title;
private string authors;
private string subject;
private int book_id;
public void getValues(string t, string a, string s, int id)
{
title = t;
authors = a;
subject = s;
book_id = id;
}
public void display()
{
Console.WriteLine("Buku yang dimaksud memiliki spesifikasi seperti berikut : ");
Console.WriteLine("Title = {0}", title);
Console.WriteLine("Authors = {0}", authors);
Console.WriteLine("Subject = {0}", subject);
Console.WriteLine("Book ID = {0}", book_id);
}
};
public class testStructure
{
static void Main(string[] args)
{
book Book1 = new book();
book Book2 = new book();
Book1.getValues("C Programming", "Nuha Ali", "C Programming Tutorial", 6495407);
Book2.getValues("Telecom Billing", "Zahra Ali", "Telecom Billing Tutorial", 6495700);
Console.WriteLine("Buku 1 ID = 6495407");
Console.WriteLine("Buku 2 ID = 6495700 \n");
Console.WriteLine("Masukkan ID : ");
int a = int.Parse(Console.ReadLine());
if (a == 6495407)
{
Book1.display();
}
if (a == 6495700)
{
Book2.display();
}
Console.ReadKey();
}
}
}
}