当前位置:天才代写 > 考试助攻 > CS代写之java代写Project Sample Scenario and Class Creation – Stage 1

CS代写之java代写Project Sample Scenario and Class Creation – Stage 1

2018-08-18 08:00 星期六 所属: 考试助攻 浏览:927

 

image.png 

 

School of Business Vocational Education

 

Course Name: Apply Introductory Object Oriented Language Skills Course Code: COSC7374


Project Sample Scenario and Class Creation – Stage 1

This document provides an example scenario to show how the program classes can be generated

from the scenario description.

Sample Scenario Description                                                                                        You have been contracted to create a program that allows an educational institution to keep track (i.e. record and retrieve details) of the different staff members (including which type of staff member they are – e.g. administration, teaching, security, cleaning, etc. – and their name, staff number, age, etc.), and the students (also including type of student – e.g. full fee paying, international, etc. – and their name, student number, age, etc.) at the institution.

Develop the Required Classes                                                                                       For Stage 1 of the project we will concentrate on creating just two classes, which will be the most general class that we can derive from the scenario. As we progress we will begin to establish other classes that contain more specific detail related to each type of staff member and student.

The most general class that we could develop from the above scenario is a Person class and Educational Institution. That will be our basic class. Later we will later create a general Student class, and a general StaffMember class.

We would also need to test this class to make sure that we are able to create instances of the class (objects), and access, modify, and display their data. This is done in a tester class.

For the Person class we would include attributes such as the person's given name & family name, their age or date of birth, their address, etc. For the moment we'll just include their given name(s), family name, and their age.

For the Educational Institution class we will have attributes as

So what we have is: a Person class, with attributes: givenName, familyName, and age. We also need to include getter (accessor) and setter (mutator) methods, and at least one constructor (see Week 4 handout ) – we'll actually put two in as per the project description; and, PersonTester class.

Initial Class Diagram

 image.png

Person

 


 

 

PersonTester

 

+ main (String[]): void

– age: int

– givenName: String  

– familyName: String

– uni: EducationalInstitution

 

+ Person()

+ Person (String, String, int)

+ setGivenName (String): void

+ getGivenName(): String

+ setFamilyName (String): void

+ getFamilyName(): String

+ setAge (int): void

+ getAge(): int

+ setUni(EducationalInstitution): void

+ getUni():EducationalInstitution


 

Java Code (also present as a zipped file)

The Person Class

 

public class Person{
// Person attributes
private int age;
private String givenName;
private String familyName;
private EducationalInstitution uni;
 
// the constructors
Person () { // this one emulates the default constructor age = 0;
givenName = null; familyName = null; uni = null;
}
Person (String gName, String fName, int howOld, EducationalInstitution eI) { age = howOld;
givenName = gName; familyName = fName; uni = eI;
}
 
// the mutators
public void setGivenName (String gName) { givenName = gName;
}
public void setFamilyName (String fName) { familyName = fName;
}
public void setAge (int howOld) { age = howOld;
}
public void setUni(EducationalInstitution eI) {
this.uni = eI;
}
 
// the accessors
public String getGivenName () {
return givenName;
}
public String getFamilyName () {
return familyName;
}
public int getAge () {
return age;
}
public EducationalInstitution getUni() {
return uni;
}
 
// make attributes available for display
public String toString () {
return "\nFamily Name: " + familyName + "\nFirst Given Name: " + givenName + "\nAge: " + age + "\n"+uni.toString();
}
 
} // end Person class


Educational Institution class:

public class EducationalInstitution {
private String name;
private String city;
 
public EducationalInstitution(String n, String c) {
super(); name = n; city = c;
}
public String getName() {
return name;
}
public void setName(String n) { name = n;
}
public String getCity() {
return city;
}
public void setCity(String c) { city = c;
}
@Override
public String toString() {
return "Student of: " + name + "\nCity: " + city;
}
}

The PersonTester Class

public class PersonTester{
/**
* The program uses Person and Educational Institution objects, and gathers info
* about their given names, family names, ages and Institution details.
* It then displays that information.
*/
public static void main (String [] args) {
//create three phone objects EducationalInstitution e1 = new
EducationalInstitution("RMIT","Melbourne");
// create three Person objects
Person p1 = new Person("RMIT","Citizen",22,e1);
// assign attribute data p1.setGivenName ("John"); p1.setFamilyName ("Citizen"); p1.setAge (22);
 
// repeat the above for Person p2 & p3
 
// display the Person data
System.out.println ("Displaying the person information ...");
// When displaying the contents of an object using print() or println()
// Java automatically looks for a toString() method, and, if available
// uses it to display the object contents. System.out.println (p1.toString());
 
// repeat display for p2 & p3
 
} // end main()
 
} // end PersonTester class

代写CS&Finance|建模|代码|系统|报告|考试

编程类:C代写,JAVA代写 ,数据库代写,WEB代写,Python代写,Matlab代写,GO语言,R代写

金融类统计,计量,风险投资,金融工程,R语言,Python语言,Matlab,建立模型,数据分析,数据处理

服务类:Lab/Assignment/Project/Course/Qzui/Midterm/Final/Exam/Test帮助代写代考辅导

天才写手,代写CS,代写finance,代写statistics,考试助攻

E-mail:850190831@qq.com   微信:BadGeniuscs  工作时间:无休息工作日-早上8点到凌晨3点


如果您用的手机请先保存二维码到手机里面,识别图中二维码。如果用电脑,直接掏出手机果断扫描。

1513067809116994.png

 

    关键字:

天才代写-代写联系方式