Skip to content
Snippets Groups Projects
Commit 438b920c authored by Marcel Kehrberg's avatar Marcel Kehrberg
Browse files

comments for class Car

parent fdaafc9e
No related branches found
No related tags found
No related merge requests found
using System; using System;
namespace ConsoleApplication1 namespace ConsoleApplication1
{ {
//Class for the objects which get stored in the buffer from the class Producer and deleted from the class Consumer
public class Car public class Car
{ {
static int carId = 0; static int carId = 0;
private int thisCarId; private int thisCarId;
// Constructor which sets the car id and increments ++ the carId for the next object
public Car() public Car()
{ {
thisCarId = carId; thisCarId = carId;
carId++; carId++;
Console.WriteLine("car created. id = " + thisCarId); Console.WriteLine("car created. id = " + thisCarId);
} }
public void count() // Destructor which decrements -- the carId
~Car()
{ {
for (int i = 0; i < 100; i++) carId--;
{ Console.WriteLine("car deleted. id = " + thisCarId);
Console.WriteLine(i);
}
} }
// Returns the carId for Consumer and Producer so they can get the carId
public int getThisCarId() public int getThisCarId()
{ {
return thisCarId; return thisCarId;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment