OneCompiler

project class

115

Create class Project (id, name, location). Define parameterized constructor.
Keep a count of each object created and display the details of each project. in scala
class Project(id:Int, name:String, location:String)
{
private var count = 0
count += 1
def displayDetails()
{
println("Project id: "+id)
println("Project Name: "+name)
println("Project Location: "+location)
println("Total Projects created: "+count)
}
}

object MainObject
{
def main(args:Array[String])
{
var p1 = new Project(1, "Project1", "Delhi")
p1.displayDetails()
var p2 = new Project(2, "Project2", "Mumbai")
p2.displayDetails()
}