Lab Oop
Lab Oop
CSC435
//Data Members
private String Prog_Code;
private String Prog_Desc;
private int Prog_duration;
private String Faculty;
private String Prog_Head;
//Method members
//Default Constructor
public Program()
{
Prog_Code = "";
Prog_Desc = "";
Prog_duration = 0;
Faculty = "";
Prog_Head = "";
}
//Normal Constructor
public Program(String PC, String PDesc, int Pdura, String Fc,
String PH)
{
Prog_Code = PC;
Prog_Desc = PDesc;
Prog_duration = Pdura;
Faculty = Fc;
Prog_Head = PH;
}
//Copy Constructor
public Program(Program p)
{
Prog_Code = p.Prog_Code;
Prog_Desc = p.Prog_Desc;
Prog_duration = p.Prog_duration;
Faculty = p.Faculty;
Prog_Head = p.Prog_Head;
}
//Mutator/Setter method
public void setProg_Code(String PC)
{
Prog_Code = PC;
}
public void setProg_Desc(String PDesc)
{
Prog_Desc = PDesc;
}
//Retriever
public String getProg_Code()
{
return Prog_Code;
}
default:
return "Unknown Program Level";
}
}
else
{
return "Invalid Program Code";
}
}
//Printer
public String toString()
{
return "\n\nProgram code: " + Prog_Code + "\nProgram
Description: " + Prog_Desc + "\nProgram Duration: " + Prog_duration +
"\nFaculty: " + Faculty + "\nProgram Header: " + Prog_Head;
}
}
• ProgramApp main
import java.util.*;
//Step 2 Input
//Setter
scan.nextLine();
//normal Constructor
//Data Members
private int Id;
private String Owner_Name;
private char house_type;
private double area;
//Method members
//Default Constructor
public Land()
{
Id = 0;
Owner_Name = "";
house_type = '\0';
area = 0;
}
//Normal Constructor
public Land(int ID, String ON, char HT, double A)
{
Id = ID;
Owner_Name = ON;
house_type = HT;
area = A;
}
//Copy Constructor
public Land(Land l)
{
Id = l.Id;
Owner_Name = l.Owner_Name;
house_type = l.house_type;
area = l.area;
}
//Mutator/Setter method
public void setId(int ID)
{
Id = ID;
}
//Getter
//Processor
public double CalcTax()
{
double tax = 0;
if (house_type == 'T') {
tax = area * 10;
}
else if (house_type == 'S') {
tax = area * 15;
}
else if (house_type == 'B') {
tax = area * 20;
}
else if (house_type == 'C') {
tax = area * 30;
}
return tax;
}
public String HouseDescription()
{
String Description = "";
if (house_type == 'T') {
Description = "Terrace";
}
else if (house_type == 'S') {
Description = "Semi-Detached";
}
else if (house_type == 'B') {
Description = "Bungalow";
}
else if (house_type == 'C') {
Description = "Condominium";
}
return Description;
}
//Printer
public String toString()
{
return "\n\nUser id: " + Id + "\nOwner name: " + Owner_Name;
}
}
• LandApp main
import java.util.*;
//Step 2 Input
//Setter
scan.nextLine();
//normal Constructor