Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Task 1 “TV”

It is necessary to write a program that simulates the operation of a TV. Provide it with the ability to
switch channels: the next channel, the previous channel, the transition to the channel by number. Note
that a channel cannot have a negative number. When launched, the program should show the current
channel and offer to switch the channel by pressing any button on the keyboard. You can display the
current channel simply as a number and name. After launching the application, the program should
constantly offer to switch channels and only after the user decides to turn off the TV, end the program.

Directions:

• The role of TV must be performed by a class named TV.

• The TV class must have:

o fields / attributes:

 currentChannel - current channel


 channelLimit - number of channels

o constructor:

 TV(currentChannel) - initializes the class fields. You can make another


constructor, which will also set the number of channels.

o three methods:

 NextChannel() - switches the TV to the next channel


 PreviousChannel() - switches the TV to the previous channel
 MoveToChannel(channel) - switches the TV to the specified channel

Task 2 “Elevator”
It is necessary to write a program that simulates the operation of an elevator in an 18-story building.
When launched, the program should ask which floor and how much weight to take. If the floor number
or load is invalid, then throw an error and wait for re-entry. If the floor number and the load are valid,
then print the numbers of floors that the elevator will reach as a result of the movement in order, then
ask again which floor and what weight should be taken.

The maximum load lifted by the elevator is 200.

Directions:

• The role of the elevator must be performed by a class named Elevator.

• The Elevator class must have:

o fields / attributes:

 currentFloor - the current floor where the elevator is located


 capacity - the maximum transported weight
 maxFloor - the maximum floor that the elevator can take

o constructor:

 Elevator(currentFloor ) - initializes class properties


o three methods:

 Move(toFloor) - moves the elevator to the desired floor and displays messages about
reaching each of the floors that it passes along the way
 IsAllowableWeight(weight) - the method must return true if the specified weight is
allowed
 IsAllowableFloor(floor) - the method must return true if the specified floor is allowed

When listing the floors that the elevator passes, take into account the current floor from which the
countdown starts.

After starting the application, the program should constantly offer to enter the floor to which it is worth
moving, and only after the user decides to turn off the elevator, complete the program.

Task 3 PHONEBOOK deadline : beginning of 3 rd


week
Use classes
You need to write interactive phonebook console application.

You print menu in a loop with available functionality. Program should allow to:

1) print all entries

2) add a new student entry to the phonebook

3) search student entry by name

4) delete student entry by id

5) quit application.

Create two java classes.

class Student should have following fields: 1) id, 2) name, 3) age, 4) phone.

application class should have ArrayList of students and maintain interactive logic.

archive project folder. only one file could be submitted.

Requirements:

[50%] basic functionality is mandatory


Additional requirements:
1) [5%] You need to check the age to be in reasonable range.

2) [5%] You should check the length of the phone string, [10%] and perform additional reasonable
checks on the phone string.

3) [10%] Use "switch case default" statement.

4) [10%] Use setter and getter functions.

5) [10%] Clean code

Below is sample output for the hint.

====================

Hello! This is phonebook!


1. To print all
2. To add
3. To search
4. To delete
5. To quit
[in]2
adding new entry
input student's name
[in]John
input student's age (0 ... 150)
[in]22
input student's phone (less than 13 characters)
[in]+77776665544

Hello! This is phonebook!


1. To print all
2. To add
3. To search
4. To delete
5. To quit
[in]2
adding new entry
input student's name
[in]Bill
input student's age (0 ... 150)
[in]23
input student's phone (less than 13 characters)
[in]+77784443322
Hello! This is phonebook!
1. To print all
2. To add
3. To search
4. To delete
5. To quit
[in]1
=====================
(id 0) John; 22 years old; +77776665544
(id 1) Bill; 23 years old; +77784443322
=====================

Hello! This is phonebook!


1. To print all
2. To add
3. To search
4. To delete
5. To quit
[in]5

Process finished with exit code 0

====================

You might also like