Q1.]Create a class Student and inherit it in UGstudent clas , PGstudent class with various functions like name,rollno,branch,student,etc
using System;
using System.Collections.Generic;
namespace App
{
abstract class Student {
private String name;
private String registerNumber;
private String department;
private String specialization;
private int cgpa;
private String hostelName;
private String mentorName;
private int numberArrears;
public Student() {
}
public Student(String name, String registerNumber, String department, String specialization, int cgpa,
String hostelName, String mentorName, int numberArrears) {
this.name = name;
this.registerNumber = registerNumber;
this.department = department;
this.specialization = specialization;
this.cgpa = cgpa;
this.hostelName = hostelName;
this.mentorName = mentorName;
this.numberArrears = numberArrears;
}
public override string ToString() {
return "Name: " + this.name + "\n" + "Register number: " + this.registerNumber + "\n" + "Department: "
+ this.department + "\n" + "Specialization: " + this.specialization + "\n" + "CGPA: " + this.cgpa + "\n"
+ "Hostel name: " + this.hostelName + "\n" + "Mentor name: " + this.name + "\n" + "Number arrears: "
+ this.numberArrears + "\n";
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the registerNumber
*/
public String getRegisterNumber() {
return registerNumber;
}
/**
* @param registerNumber the registerNumber to set
*/
public void setRegisterNumber(String registerNumber) {
this.registerNumber = registerNumber;
}
/**
* @return the department
*/
public String getDepartment() {
return department;
}
/**
* @param department the department to set
*/
public void setDepartment(String department) {
this.department = department;
}
/**
* @return the specialization
*/
public String getSpecialization() {
return specialization;
}
/**
* @param specialization the specialization to set
*/
public void setSpecialization(String specialization) {
this.specialization = specialization;
}
/**
* @return the cgpa
*/
public int getCgpa() {
return cgpa;
}
/**
* @param cgpa the cgpa to set
*/
public void setCgpa(int cgpa) {
this.cgpa = cgpa;
}
/**
* @return the hostelName
*/
public String getHostelName() {
return hostelName;
}
/**
* @param hostelName the hostelName to set
*/
public void setHostelName(String hostelName) {
this.hostelName = hostelName;
}
/**
* @return the mentorName
*/
public String getMentorName() {
return mentorName;
}
/**
* @param mentorName the mentorName to set
*/
public void setMentorName(String mentorName) {
this.mentorName = mentorName;
}
/**
* @return the numberArrears
*/
public int getNumberArrears() {
return numberArrears;
}
/**
* @param numberArrears the numberArrears to set
*/
public void setNumberArrears(int numberArrears) {
this.numberArrears = numberArrears;
}
}
class PGstudent : Student {
private int level;
public PGstudent(String name, String registerNumber, String department, String specialization, int cgpa, String hostelName,
String mentorName, int numberArrears, int level):base(name, registerNumber, department, specialization, cgpa, hostelName, mentorName, numberArrears) {
this.level = level;
}
public override string ToString()
{
return base.ToString() + "Level: " + this.level + "\n";
}
/**
* @return the level
*/
public int getLevel() {
return level;
}
/**
* @param level the level to set
*/
public void setLevel(int level) {
this.level = level;
}
}
class UGstudent : Student {
private int fees;
public UGstudent(String name, String registerNumber, String department, String specialization, int cgpa, String hostelName,
String mentorName, int numberArrears, int fees):base(name, registerNumber, department, specialization, cgpa, hostelName, mentorName, numberArrears) {
this.fees = fees;
}
public override string ToString()
{
return base.ToString() + "Fees: " + this.fees + "\n";
}
/**
* @return the fees
*/
public int getFees() {
return fees;
}
/**
* @param fees the fees to set
*/
public void setFees(int fees) {
this.fees = fees;
}
}
class Program
{
static void Main(string[] args)
{
Console.ReadLine();
}
}
}
Comments
Leave a comment