בי מאסטר (Bmaster)מאגר שאלות בגרותשאלות נפוצותמדריכיםארכיון בגרויות
תפריט

חומרי לימוד

מאגר שאלות בגרותשאלות נפוצותמדריכיםארכיון בגרויות
חזרה למאגר2016 קיץ מועד ב

מערכת כלי תחבורה וירושה

שאלה קודמתשאלה הבאה
שאלה 13מבני נתונים2016 קיץ מועד ב

מערכת כלי תחבורה וירושה

לפניך חלק מפרויקט העוסק בכלי תחבורה וכולל את המחלקות: Vehicle, Train, Boat, Airplane, TransportationCompany.

1public class Vehicle {
2    private String type;
3    private String way;
4    private int maxSpeed;
5    public Vehicle(String type, String way, int maxSpeed) {
6        this.type = type;
7        this.way = way;
8        this.maxSpeed = maxSpeed;
9    }
10}
11
12public class Train extends Vehicle {
13    private int numOfCarriages;
14    public Train(int maxSpeed, int numOfCarriages) {
15        super("land", "tracks", maxSpeed);
16        this.numOfCarriages = numOfCarriages;
17    }
18    public void incNumOfCarriages(int n) {
19        this.numOfCarriages = this.numOfCarriages + n;
20    }
21}
22
23public class Boat extends Vehicle {
24    public Boat(String way, int maxSpeed) {
25        super("water", way, maxSpeed);
26    }
27}
28
29public class Airplane extends Vehicle {
30    private int maxHeight;
31    public Airplane(int maxSpeed, int maxHeight) {
32        super("sky", "air", maxSpeed);
33        this.maxHeight = maxHeight;
34    }
35}
36
37public class TransportationCompany {
38    private Vehicle[] vehicles = new Vehicle[50];
39    private int counter = 0;
40    public void addVehicle(Vehicle v) {
41        this.vehicles[counter] = v;
42        this.counter++;
43    }
44}

משימות

אמשימה אcode

ממש ב-Java מחלקה ראשית Program ובה פעולה ראשית שתבצע:

  1. בניית עצם TransportationCompany בשם company1.
  2. הוספת סירה אחת ורכבת אחת לחברה.
במשימה בcode

במחלקה TransportationCompany הוגדרה פעולה display המדפיסה את המערך. ממש ב-Java פעולות שיאפשרו ביצוע תקין של display כך שיודפסו כל תכונות כלי התחבורה. השתמש בפולימורפיזם.

גמשימה גcode

ממש ב-Java פעולה שתקבל מספר שלם n ותוסיף n קרונות לכל הרכבות בחברה.

שאלה 13מבני נתונים2016 קיץ מועד ב

מערכת כלי תחבורה וירושה

לפניך חלק מפרויקט העוסק בכלי תחבורה וכולל את המחלקות: Vehicle, Train, Boat, Airplane, TransportationCompany.

1public class Vehicle {
2    private String type;
3    private String way;
4    private int maxSpeed;
5    public Vehicle(String type, String way, int maxSpeed) {
6        this.type = type;
7        this.way = way;
8        this.maxSpeed = maxSpeed;
9    }
10}
11
12public class Train extends Vehicle {
13    private int numOfCarriages;
14    public Train(int maxSpeed, int numOfCarriages) {
15        super("land", "tracks", maxSpeed);
16        this.numOfCarriages = numOfCarriages;
17    }
18    public void incNumOfCarriages(int n) {
19        this.numOfCarriages = this.numOfCarriages + n;
20    }
21}
22
23public class Boat extends Vehicle {
24    public Boat(String way, int maxSpeed) {
25        super("water", way, maxSpeed);
26    }
27}
28
29public class Airplane extends Vehicle {
30    private int maxHeight;
31    public Airplane(int maxSpeed, int maxHeight) {
32        super("sky", "air", maxSpeed);
33        this.maxHeight = maxHeight;
34    }
35}
36
37public class TransportationCompany {
38    private Vehicle[] vehicles = new Vehicle[50];
39    private int counter = 0;
40    public void addVehicle(Vehicle v) {
41        this.vehicles[counter] = v;
42        this.counter++;
43    }
44}

משימות

אמשימה אcode

ממש ב-Java מחלקה ראשית Program ובה פעולה ראשית שתבצע:

  1. בניית עצם TransportationCompany בשם company1.
  2. הוספת סירה אחת ורכבת אחת לחברה.
במשימה בcode

במחלקה TransportationCompany הוגדרה פעולה display המדפיסה את המערך. ממש ב-Java פעולות שיאפשרו ביצוע תקין של display כך שיודפסו כל תכונות כלי התחבורה. השתמש בפולימורפיזם.

גמשימה גcode

ממש ב-Java פעולה שתקבל מספר שלם n ותוסיף n קרונות לכל הרכבות בחברה.