Create the package named by,gsu,epamlab and define the class, describing a trainee trial (see classes-eclipse,doc)

Страницы работы

4 страницы (Word-файл)

Содержание работы

Task 1

Create the package named by.gsu.epamlab and define the class, describing a trainee trial (see classes-eclipse.doc).

Define the Runner class in the default package, where:

1. Create two objects representing two trials using general-purpose constructor.

2. Change an account of the first trial to the value Loser if the trial is not passed.

3. Print trials.

4. Create an array for 5 objects using general-purpose constructor.

5. Print an array to the console.

6. Find sums of marks for each test.

7. Find the number of passed trials.

Task 2

Create the package named by.gsu.epamlab and define the class, describing a trainee trial (see classes-eclipse.doc).

Input text file contains a sequence of 7 correct lines. Every line contains one string and two natural numbers from 1 to 100.

Example of the line

Sakovich   35    71

Define the Runner class in the default package, where:

1. Create an array for 7 objects.

2. Initialize an array by the file contents.

3. Print an array to the console.

4. Find average values of marks for each test.

5. Create the trial with average values of marks (rounded to integer) and find whether this trial is passed.

6. Clear marks for not passed trials.

7. Print an array to the console.

Task 3

Create the package named by.gsu.epamlab for the entities classes.

Define the class Purchase, describing a purchase of some commodity.

Class fields:

●  commodity name,

●  price in belarusian rubles,

●  number of purchased units.

Constructors:

●  default constructor,

●  general-purpose constructor.

Methods:

●  getters/setters;

●  getCost( ) – calculating the purchase cost (= price * number);

●  toString( ) – converting of an object to a string in the csv–format: each field and the purchase cost, separated by the ";" symbol.

Define the Runner class in the default package, where:

1. Create the object representing the purchase of 5 magazines at a price of 15 000 belarusian rubles.

2. Print this object to the console, using toString( ) method.

3. Change the number of purchased units on 3 and print the purchase cost.

4. Create another object representing the purchase of 5 books at a price of 70 000 belarusian rubles.

5. Print the object content to the console, using toString( ) method.

6. Change commodity of the second purchase on a magazine at a price of 25 000 belarusian rubles and print its cost.

7. Create an array for 5 objects.

8. Initialize an array by the file in.txt contents.

9. Print an array to the console.

Task 4, Common part

Create the package named by.gsu.epamlab for the entities classes.

Define the class Commodity, describing the commodity.

Class fields:

●  commodity name,

●  price in belarusian rubles,

Constructors:

●  default constructor,

●  general-purpose constructor.

Methods:

●  getters/setters;

●  toString( ) – converting of an object to a string in the csv–format: each field, separated by the ";" symbol.

Define the class Purchase, describing the commodity purchase.

Class fields:

●  commodity,

●  number of purchased units.

Constructors:

●  default constructor,

●  general-purpose constructor.

Methods:

●  getters/setters;

●  getCost( ) – calculating the purchase cost (= price * number);

●  toString( ) – converting of an object to a string in the csv–format: each field and the purchase cost, separated by the ";" symbol.

Variant 1

Define the Runner class in the default package, where:

1. Create the object representing the magazine at a price of 15 000 belarusian rubles.

2. Create the object representing the purchase of 5 magazines.

3. Print last object to the console, using toString( ) method.

4. Change the number of purchased units on 3 and print the purchase cost.

Variant 2

Define the Runner class in the default package, where:

1. Create two objects representing two purchases of book at a price of 70 000 belarusian rubles. The first purchase has 5 units, the second one has 12 units.

2. Print the objects content to the console, using toString( ) method.

3. Change commodity of the second purchase on a magazine at a price of 25 000 belarusian rubles and print its cost.

4. Exchange commodities for two purchases and print them.

Variant 3

Define the Runner class in the default package, where:

1. Create the object representing the magazine at a price of 15 000 belarusian rubles.

2. Create an array for 5 purchases of this magazine.

3. Print the array content to the console.

4. Calculate the total cost of all purchases.

5. How much purchases has the number of purchased units less than 10?

Variant 4

Define the Runner class in the default package, where:

1. Create 3 commodities: magazine at a price of 15 000 belarusian rubles, magazine at a price of 20 000 belarusian rubles, book at a price of 90 000 belarusian rubles.

2. Create an array for 10 purchases (all combinations of commodities are possible).

3. Print the array content to the console.

4. Calculate the average cost of magazines, the total number of purchased books.

5. Update the book price on 85 000 belarusian rubles.

6. Update purchases where commodity is a magazine at a price of 15 000 belarusian rubles. New commodity is a book at a price of 150 000 belarusian rubles.

7. Print the array content to the console.

Task 5

Create the package named by.gsu.epamlab and define the class, describing monthly expenses for a phone line.

Class fields:

●  account,

●  month (enumeration),

●  constant monthly fee;

●  minute rate for calls within the city;

●  number of called minutes within the city;

●  unified minute rate for calls outside of the city;

●  number of called minutes outside of the city.

Constructors:

●  default constructor;

●  general-purpose constructor.

Methods:

●  getters/setters;

●  getCost( ) – calculating monthly expenses for a phone line;

●  toString( ) – converting of an object to a string in the csv–format: each nonconstant field and monthly expenses, separated by the ";" symbol.

Define the Runner class in the default package, where:

1. Create an array for the first half year expenses for 2 persons.

2. Print an array to the console.

3. Find who paid more.

4. Calculate average expenses for each month.

Похожие материалы

Информация о работе