• Aucun résultat trouvé

Object Design

N/A
N/A
Protected

Academic year: 2022

Partager "Object Design"

Copied!
2
0
0

Texte intégral

(1)

Universit´e Bordeaux I Master .

Examen Module Object Oriented Design.

Object Design

Exercise 1

Correct the code below in order to suppress all compilation errors.

class AClass {

private String ident;

static int val;

public Aclass (String ident){

this.ident=ident;

}

public void getIdent(){

return ident;

}

public display(){

System.out.println(‘‘id ’’ +ident);

}

Class SubClass extends AClass{

private int category;

public SubClass(){

super(‘‘no id’’);

category=0;

}

public AClass(String name){

super(ident);

this.category=0;

}

public int getCounter(){

return category;

}

public modify(int val ){

category =val;

}

public void display() {

System.out.println(‘‘my id is’’+ident);

Syntem.out.println(‘‘my category is ‘‘ + category);

} }

class Main{

public void main(String args) {

subclass item1=new SubClass(2);

SubClass item2=new SubClass{‘‘foo’’);

item2.add(1);

AClass item3=new AClass();

item3.modify();

AClass item4 = new SubClass();

item1.display();

item4.display();

} }

1

(2)

Exercise 2

1. Why when you execute a java program you have to give the name of the class which contains themainto the virtual machinejava?

2. In both the classAClassandSubClass, we can see the same method namedisplay, how do you call this programming concept? Why we use it ?

3. What you have to do to use in your program a class which belongs to the packagejava.lang, why ?

3 Problem

NB: To propose the code of this problem you can consider that the methods input stringandinput int (identical to this one we have seen in the lesson) are available and can be called to input variable from the keyboard.

The Ho Chi Minh city movie theater complex administration wants to improve its programmation procedures and has bought a computer for this goal. So, our company asks you to design a new application essential to achieve this task.

The waited program has to manage 2 movie theater complexes. For each one, you have to implement a module that manage the programming task made each week by the administrator of the complexes.

The avaible movies are classified in several categories:

1. adventure 2. social chronicles 3. science fiction

4. cartoons and movies for children.

The 2 movie theater complexes: the Select and the Hollywood, have 3 screens each. The viewing sessions take place at 18h, 20h, 22h for all screens but the Select can add viewing session for a cartoon or a movie for children at 16h (these movies can also be programmed at the other times).

Rules to create the weekly programAll the available movies can be program in any screens of all cinemas but the same movie can not be programmed at the same time in 2 different screens of the same complexe (in the case of it exists several copies of the same movie)

What you have to do Implement the classes that you need to code the elements of this problem. Implement a Main class that contains themainwith a menu that asks to the user what he wants to do :

• to create the list of the available movies for the week.

• to create the program of each theater,

• to display the program of one of the theater selecting by the name given by the user.

• to store the whole program in a text file.

• to restore a program from a text file saving previously by your program.

2

Références

Documents relatifs

“the distance between the robot and the human operator is always greater than or equal

- In-vivo: Students enrolled in a course use the software tutor in the class room, typically under tightly controlled conditions and under the supervision of the

The letter was from a law firm in New York, and the attorney’s name was Thomas Campbell who was writing a letter on behalf of the artist Mary Ellen Carroll and it was

have shown, in [CP12], that there exists no algorithm computing a simple and equitable fair division for n ≥ 3 players in the Roberston-Webb model.. The strategy used in these

By direct inspection, the reduced row echelon form of the corresponding matrix has two pivots, so there are 98 free variables, and the dimension is 98.. Since dim P 2 = 3, it is

A two-dimensional representation is either irreducible or has an invariant one-dimensional subspace, which corresponds to a common eigenvector of all transformations representing

I believe that our College has already begun forging this trail through Canadian health care culture—we’ve called it the patient’s medical home, and we

In this situation, Polanyi’s idea of ictitious commodiication afords a promising basis for an integrated structural analysis that connects three dimensions of the