[go: up one dir, main page]

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

Assignment-1: Name of Student:Patekar Umesh B. Batch:D3 Branch:Computer Roll No77 Problem Statement

The document describes an assignment to implement a Participant class for a dance club audition based on the provided class diagram and description, with the Participant class containing fields for registration ID, name, contact number, and branch along with getter and setter methods. Sample input is provided to test creating two Participant objects with different names, contact numbers, and branches, and the expected output verifies the registration IDs are generated correctly. The Participant class code implements the requirements, creating objects that output the correct registration IDs when printed.

Uploaded by

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

Assignment-1: Name of Student:Patekar Umesh B. Batch:D3 Branch:Computer Roll No77 Problem Statement

The document describes an assignment to implement a Participant class for a dance club audition based on the provided class diagram and description, with the Participant class containing fields for registration ID, name, contact number, and branch along with getter and setter methods. Sample input is provided to test creating two Participant objects with different names, contact numbers, and branches, and the expected output verifies the registration IDs are generated correctly. The Participant class code implements the requirements, creating objects that output the correct registration IDs when printed.

Uploaded by

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

Assignment-1

Name of Student:Patekar Umesh B.

Batch:D3 Branch:Computer Roll No77

Problem Statement
A VIT Melange committee is conducting auditions to admit interested candidates. You need to
implement a Participant class for the dance club based on the class diagram and description given
below.

C-Participants

 counter: int
 registrationId: String
 name: String
 contactNumber: long
 branch: String

o C
Participant(name:String,contactNumber:long,branch:String)
o getRegistrationId(): String
o getCounter(): int
o setCounter(counter:int):void
o getName():String
o setName(name:String):void
o getContactNumber():long
o setContactNumber(contactNumber:long):void
o getBranch():String
o setBranch(branch:String):void

Method Description
Partcipant(String name, long contactNumber, String branch)
 Initialize the name, contactNumber and branch instance variables appropriately with the
values passed to the constructor.
 Generate the registrationId using the static variable counter.
 The value of registrationId should start from 'D1001' and the numerical part should be
incremented by 1 for the subsequent values.
 Initialize the counter in static block.
Implement the appropriate getter and setter methods.
Test the functionalities using the provided Tester class. Create two or more Participant objects and
validate that the values of the member variables are proper.
Sample Input and Output
For constructor
Input
For first Participant object

Parameters Values
name Rohit
contactNumber 1234567889
branch Computer

For second Participant object

Parameters Values
name Sayli
contactNumber 1988612300
branch Mechanical

Expected Output

Hi Rohit! Your registration id is D1001


Hi Sayli! Your registration id is D1002

Code :-
public class Participant{
private String name;
private String branch;
private String registrationId;
private long contactNumber;
private static int counter;

static
{
counter=1001;
}
Participant(String name,long contactNumber,String branch)
{
this.name=name;
this.branch=branch;
this.contactNumber=contactNumber;
this.registrationId="D"+counter;
counter++;
}
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
public String getBranch(){
return branch;
}
public void setBranch(String branch){
this.branch=branch;
}
public long getContactNumber(){
return contactNumber;
}
public void setContactNumber(long contactNumber){
this.contactNumber=contactNumber;
}
public static int getCounter(){
return counter;
}
public static void setCounter(int counter){
Participant.counter=counter;
}
public String getRegistrationId(){
return registrationId;
}
public static void main(String[]args)
{
Participant student1=new Participant("Rohit",1234567889,"Computer");
Participant student2=new Participant("Sayli",1988612300,"Mechanical");
System.out.println("Hi "+student1.getName()+"!Your registration id is "+student1.getRegistrationId());
System.out.println("\n Hi "+student2.getName()+"! Your registration id is "+student2.getRegistrationId());
}
}

Results:
Actual Output

You might also like