0% found this document useful (0 votes)
4 views3 pages

15# Classes & Objects Object Oriented Programming Attributes

The document contains C# code defining two classes, Person and Product, within the 'darklter' namespace. The Person class has attributes for first name, last name, sex, and age, while the Product class includes attributes for product name, description, price, and quantity. The Program class demonstrates the instantiation of these objects and outputs specific attributes to the console.

Uploaded by

Lesunter KLter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

15# Classes & Objects Object Oriented Programming Attributes

The document contains C# code defining two classes, Person and Product, within the 'darklter' namespace. The Person class has attributes for first name, last name, sex, and age, while the Product class includes attributes for product name, description, price, and quantity. The Program class demonstrates the instantiation of these objects and outputs specific attributes to the console.

Uploaded by

Lesunter KLter
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

15# Classes & Objects Object Oriented Programming Attributes

//////////////
//Person.cs//
//\\\\\\\\\\\

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

namespace darklter
{
internal class Person
{
public string firstName;
public string lastName;
public char sex;
public int age;
}
}

///////////////
//Product.cs//
//\\\\\\\\\\\\

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

namespace darklter
{
internal class Product
{
public string productName;
public string productDescription;
public float productPrice;
public int productQty;
}
}

///////////////
//Program.cs//
//\\\\\\\\\\\\

using System;
namespace darklter
{
class Program
{
static void Main(string[] args)
{
Person p1 = new Person();
p1.firstName = "David";
p1.lastName = "Sdpt";
p1.age = 21;
p1.sex = 'M';

Person p2 = new Person();


p2.firstName = "Alenere";
p2.lastName = "Sdpt";
p2.age = 19;
p2.sex = 'F';

Person p3 = new Person();


p3.firstName = "Jaymar";
p3.lastName = "Catapang";
p3.age = 23;
p3.sex = 'M';

Person p4 = new Person();


p4.firstName = "Sean";
p4.lastName = "Sdpt";
p4.age = 12;
p4.sex = 'M';

Person p5 = new Person();


p5.firstName = "Patrick";
p5.lastName = "Macaraig";
p5.age = 18;
p5.sex = 'M';

Console.WriteLine(p5.firstName + " " + p5.lastName);

///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////

using System;
namespace darklter
{
class Program
{
static void Main(string[] args)
{
Product p1 = new Product();
p1.productName = "Milk";
p1.productDescription = "Milkyway Galaxy";
p1.productPrice = 150;
p1.productQty = 5;

Product p2 = new Product();


p2.productName = "Coke";
p2.productDescription = "1.5L";
p2.productPrice = 75;
p2.productQty = 25;

Console.WriteLine(p2.productName);
}
}
}

You might also like