Hii all :D How are you ? Hope Everything is gr8

first ,sorry for any language mistakes , but English is not my native language :)

This is my Code which has 5 class
1. district.
2. region.
3.MinsteryOdEducation
4.main
5.SchoolGroup

all the codes are below .. I design it according to the docx. file :)

it almost done !but I don't know how to make some of the functions ,

public class District {
// variable for District Name ...

    private String DistrictName;
// an array with an initail value for makkah district
    private Region MakkahDistrictRegions[] = new Region[3];

    // zero argument constructor
    District() {
        this.DistrictName = null;
        Region MakkahDistrictRegions[] = {new Region("Makkah", new District("Makkah"))
                                         , new Region("Jeddah", new District("Makkah"))
                                         , new Region("Taif", new District("Makkah"))};
    }
// constructor with argument

    District(String DistrictName) {
        this.DistrictName = DistrictName;
    }

// set function for the District Name
    public void setDistrictName() {
        this.DistrictName = DistrictName;
    }
// geta function for the District Name

    public String getDistrictName() {
        return DistrictName;
    }

    // get for the array
    public Region[] getMakkahDistrictRegions ()
    {

        return MakkahDistrictRegions ;
    }
}
public class Region {
// variable for the region Name 

    private String RegionName;
    private District District;

    private SchoolGroup[] MakkahSchool;
    private SchoolGroup[] JeddahSchool;
    private SchoolGroup[] TaifSchool;
// Zero argument Constrctor
    Region() {
        this.RegionName = null;
        MakkahSchool = new SchoolGroup[3];
        // for Makkah region...
        MakkahSchool[0] = new SchoolGroup("Primary School",50, 100, 400, 13000);
        MakkahSchool[1] = new SchoolGroup("Intermediate School",35, 80, 400, 12000);
        MakkahSchool[2] = new SchoolGroup("High School",30, 90, 450, 10000);
        
       
        // for Jeddah region...

        JeddahSchool = new SchoolGroup [3];
        JeddahSchool[0]= new SchoolGroup ("Primary School",100, 500, 1000, 40000);
        JeddahSchool[1]= new SchoolGroup("Intermediate School",87, 700, 3000, 35000);
        JeddahSchool[2]= new SchoolGroup ("High School",78, 7000, 5000, 33000); 

        // and for Taif Regigon .... 

        TaifSchool = new SchoolGroup [3];
        TaifSchool[0]= new SchoolGroup("Primary School",50, 100, 400, 13000);
        TaifSchool[1]= new SchoolGroup("Intermediate School",45, 200, 2000, 15000);
        TaifSchool[2]=  new SchoolGroup("High School",32, 400, 3000, 13000);      
    }

   
    
// constructor with argument

    Region(String RegionName, District district) {
        this.RegionName = RegionName;
        this.District = district;
    }
// set function for the region name

    public void setName() {
        this.RegionName = RegionName;
        this.District = District;
    }

    // get function for makkah schools array
    public SchoolGroup[] getMakkahSchools ()
    {
        return MakkahSchool;
    }
 // get function for Jeddah schools array
    public SchoolGroup[] getJeddahSchools ()
    {
        return JeddahSchool;
    }
 // get function for Taif schools array

    public SchoolGroup[] getTaifSchools()
    {
        return TaifSchool;
    }
// get functions for the reagion name 

    public String getRegionName() {
        return RegionName;
    }
}
public class SchoolGroup {
// Protected variables with type intger " protected b-coz i may need to inhert this classs "

    protected String schoolType ;
    protected int adminEmpNum;
    protected int teachersNum;
    protected int studentsNum;
    protected int numOfSchools;

    SchoolGroup() {// Zero argument constructor
        this.schoolType = null;
        this.adminEmpNum = 0;
        this.numOfSchools= 0;
        this.studentsNum = 0;
        this.teachersNum = 0;

    }
// constructor with argument

    SchoolGroup(String schoolType ,int numOfSchool, int adminmpNum, int teachersNum, int studentsNum) {
        this.schoolType = schoolType;
        this.numOfSchools = numOfSchool;
        this.adminEmpNum = adminmpNum;
        this.teachersNum = teachersNum;
        this.studentsNum = studentsNum;
    }
// seter function for all the variables

    public void setInfo() {
        this.schoolType = schoolType;
        this.teachersNum = teachersNum;
        this.numOfSchools = numOfSchools;
        this.adminEmpNum = adminEmpNum;
        this.studentsNum = studentsNum;
    }
// get the administration employees number function

    public String getSchoolType ()
    {
        return schoolType ;
    }

    public int getAdminEmpNum() {
        return adminEmpNum;
    }
// get the teachers number function

    public int getTeachersNum() {
        return teachersNum;
    }
// get the student number function

    public int getStudentsNum() {

        return studentsNum;

    }
// get the  number of schools function

    public int getNumOfSchools() {
        return numOfSchools;
    }
}
import java.util.*;

public class MinsteryOfEducation {

    District DistrictList[] = new District[13];
    Scanner input = new Scanner(System.in);

    MinsteryOfEducation() {
// an arry with type District ' which is a class ' has all kas districts
        District DistrictList[] = {new District("Makkah"), new District("Maddinah"), new District("Al Riyadh"), new District("Al Bahah"), new District("Jizan"), new District("Najran"), new District("Tabuk"), new District("Eastern Province"), new District("Asir"), new District("Ha'il"), new District("Al Qasim"), new District("Al Jawf"), new District("Northern Border")};
    }

    // The functions ::
    //Given the district, list the number of schools in that region, according to District Name.
    public void NumOfSchoolInRegions() {
        // ask the user about which district he/she wants to know about
        System.out.println("Enter the District Name :");
        String DistrictN = input.nextLine();// get whatever the user input

        // a exception should be here , dealing with a user !
        // an object of type region to call the arrays in that class
        Region region = new Region();
        SchoolGroup makkah[] = region.getMakkahSchools();
        SchoolGroup jeddah[] = region.getJeddahSchools();
        SchoolGroup taif[] = region.getTaifSchools();
        District rigions = new District();

        Region MakkahRegionsList[] = rigions.getMakkahDistrictRegions();
        ;
        //MakkahRegionsList = rigions.getMakkahDistrictRegions();
        System.out.println("Distric Name:" + DistrictN);

        for (int i = 0; i < MakkahRegionsList.length; i++) {
            System.out.printf(MakkahRegionsList[i].getRegionName() + "  ");
        }
        for (int i = 0; i < makkah.length; i++) {
            System.out.println();
        }
        {
        }
    }

    //Given the district, region, list the number of schools in that region, according to District Name.
    public void NumberOfSchoolsInRegion() {
        System.out.println("Enter the District Name :");
        String districtN = input.nextLine();
        System.out.println("Enter the Region Name :");
        String regionN = input.nextLine();

    }

    //Given the district, list the number of schools in secondary or intermediate or high schools
    public void NumberOfSpecificTypeOfSchoolsInDistrcit() {
        System.out.println("Enter the District Name :");
        String districtN = input.nextLine();

    }

    //Given the district, region, list the number of schools in secondary or intermediate or high schools.
    public void NumberOfOneTypeOfSchoolsInOneRgion() {
        System.out.println("Enter the District Name :");
        String districtN = input.nextLine();
        System.out.println("Enter the Region Name :");
        String regionN = input.nextLine();
    }

    //Given the district, display the total number of schools.
    public void TotalNumberOfSchoolsInDisetrict() {
        System.out.println("Enter the District Name :");
        String districtN = input.nextLine();

    }

    // Given the district, region, display the total number of schools.
    public void TotalNumberOfSchoolsInRegion() {
        System.out.println("Enter the District Name :");
        String districtN = input.nextLine();

        System.out.println("Enter the Region Name :");
        String regionN = input.nextLine();

    }

    //Given the district, list the number of admin employees, teachers and students, according to District Name
    public void NumberOfPPLInEachTypeOfSchoolsInEachRegion() {
    }

    //Given the district, list the number of admin employees or teachers or students
    public void NumberOfOneKindOFpplInDistrict() {

        System.out.println("Enter the District Name :");
        String districtN = input.nextLine();
    }
    //Given the district, region, list the number of admin employees or teachers or students

    public void NumberOfOneKindOFpplInRegion() {
        System.out.println("Enter the District Name :");
        String districtN = input.nextLine();

        System.out.println("Enter the Region Name :");
        String regionN = input.nextLine();
    }
    // Given the district, region, school level, list the number of admin employees, teachers and students, according to D and R

    public void NumberOfPPLInOneSchoolLevelInRegion() {
        System.out.println("Enter the District Name :");
        String districtN = input.nextLine();

        System.out.println("Enter the Region Name :");
        String regionN = input.nextLine();

    }
}
import java.util.*;

public class main {

    public static void main(String[] args) {

       MinsteryOfEducation toCall = new MinsteryOfEducation();

        int answer = 0;
        Scanner input = new Scanner(System.in);
        ;
        while (answer != 11) {
           

            System.out.println("1.Given the district, list the number of schools in that region, according to District Name.");
            System.out.println("2.Given the district, region, list the number of schools in that region, according to District Name.");
            System.out.println("3.Given the district, list the number of schools in secondary or intermediate or high schools.");
            System.out.println("4.Given the district, region, list the number of schools in secondary or intermediate or high schools.");
            System.out.println("5.Given the district, display the total number of schools.");
            System.out.println("6.Given the district, region, display the total number of schools.");
            System.out.println("7.Given the district, list the number of admin employees, teachers and students, according to District Name.");
            System.out.println("8.Given the district, list the number of admin employees or teachers or students.");
            System.out.println("9.Given the district, region, list the number of admin employees or teachers or students.");
            System.out.println("10.Given the district, region, school level, list the number of admin employees, teachers and students, according to D ,R");
            System.out.println("11. Exit");

            System.out.println("What Do you want to do ,enter a number ");
            answer = input.nextInt();
             // exception shuold be here 


            switch (answer) {

                case 1:
                    toCall.NumOfSchoolInRegions();
                case 2:
                    toCall.NumberOfSchoolsInRegion();
                case 3:
                    toCall.NumberOfSpecificTypeOfSchoolsInDistrcit();
                case 4:
                    toCall.NumberOfOneTypeOfSchoolsInOneRgion();
                case 5:
                    toCall.TotalNumberOfSchoolsInDisetrict();
                case 6:
                    toCall.TotalNumberOfSchoolsInRegion();
                case 7:
                    toCall.NumberOfPPLInEachTypeOfSchoolsInEachRegion();
                case 8:
                    toCall.NumberOfOneKindOFpplInDistrict();
                case 9:
                    toCall.NumberOfOneKindOFpplInRegion();
                case 10:
                    toCall.NumberOfPPLInOneSchoolLevelInRegion();
                default:
                    System.out.println("Sorry , wrong choic^^;");

            }
        }
    }
}

I already start doing the first one :) but it doesn't work !
So, how do you think can i implement it to do it works ?
and how do you find the code ?


thanks :D

Recommended Answers

All 3 Replies

it doesn't work

Are there errors? Please copy and paste the full text of the error message here.
Is the output wrong? Please show the current output, explain why it is wrong and show what you want the output to be.

Don't expect anyone to download and read the docx file. You need to copy and paste the parts that are giving you problems and tell us what you don't understand.

what exactly do you mean by this?

public class SchoolGroup {
// Protected variables with type intger " protected b-coz i may need to inhert this classs "

if you extend a class, you can still use it's variables and methods, the difference is the way you can access them.

ok , i'm extremely sorry !

just give me few time and i'll post the exact Question in the exact part ..


thanks & sorry again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.