联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2018-10-08 09:57

CSE1IOO-CSE4IOO Semester 2, 2018

Programming Assignment

Objectives: to practise analysing a problem in an object-oriented manner and designing and

implementing an object-oriented solution.

Due Date: 10:00am Monday October 8

th

, 2018.

1 General Information

General information about the assignment is specified in this section.

1.1 Assessment

This assignment contributes 30% of the final assessment for the subject.

1.2 Submission Instruction

Submit the electronic copy of your assignment via the ‘Online Assignment Submission’ system at

http://students.cs.latrobe.edu.au/student-tools/online-assign-submit/.

Note 1: While you are free to develop the code for this assignment on any operating system, your

solution must run on the latcs8 system.

Note 2: Please DO NOT zip your source code.

Note 3: You should only submit your .java files.

Note 4: The submission folder will only become available 3 days before the due date.

Submission after the deadline will incur a penalty of 5% of the final assignment mark per day. If

you have encountered difficulties that lead to late submission or no submission, you should apply

for special consideration. No assignment is accepted after 4 days’ delay.

1.3 Plagiarism

This is an individual assignment. Plagiarism is the submission of another person’s work in a manner

that gives the impression that the work is your own. La Trobe University treats plagiarism seriously.

When detected, penalties are strictly imposed.

Further information can be found on http://www.latrobe.edu.au/plagiarism/plagiarism.html

1.4 Programming Language

The program is required to be developed in JAVA.

1.5 Assignment Marking

The assignment will be marked during your lab session in Week 12. Your tutor will run your

program with you while marking it. The marking will be conducted from the submission area, not

from student accounts. Please ensure that your program runs on latcs8 before submission.

Page 2 of 8

2 Problem Description

You are requested to join a team to develop a software system for a karaoke machine. The software

system consists of a number of sub-systems. One of them is Lyric Displayer – to display lyrics lineby-line

on the monitor for a specified time interval. Your task is to develop the sub-system.

2.1 Definitions of Terms

A number of terms which will be utilised in the program will be defined below.

2.1.1 Line of Lyrics

A line of lyrics is a string to be displayed on the monitor. A positive number is associated with the

string that indicates the time interval (in seconds) for the string to be displayed. Below is an

example of a line of lyrics.

Figure 1 A line of lyrics

In Figure 1, it requires the string “Twinkle, twinkle, little star,” to be displayed on the

monitor for 4.4 seconds.

2.1.2 Song

A song contains a serial number which is an integer and a title which is a string. There are two types

of Songs – Solo and Duet.

2.1.2.1 Solo

A Solo is a Song to be performed by one singer. Except for the serial number and title included in

Song, it also contains an array of lyrics. An example of a Solo can be as follows.

Figure 2 A Solo

2.1.2.2 Duet

A Duet is a Song to be performed by two singers concurrently. Like Solo, it has the serial number

and title, but it contains two arrays of lyrics for both singers. An example of a Duet can be as below.

Lyrics

4.4 Twinkle, twinkle, little star,

Displaying time

2 Twinkle, twinkle, little star

4.4 Twinkle, twinkle, little star

4.2 How I wonder what you are

4.8 Up above the world so high

5.0 Like a diamond in the sky

4.4 Twinkle, twinkle, little star

5.9 How I wonder what you are

Serial number Title

An array of lyrics

Page 3 of 8

Figure 3 A Duet

2.1.3 Album

An Album contains a name (name of the album, String type) and a linked list of Song objects. An

example of an Album is as below.

Lyrics for singer 2

3 Eensy Weensy Spider

5.5 Eensy weensy spider

6.5 crawled up the water spout.

4.5 Down came the rain,

7.5 and washed the spider out.

4.5 Out came the sun

7.5 and dried up all the rain,

5.5 -

5.5 and eensy weensy spider

6.5 crawled up the spout again.

5.5 -

5.5 Eensy weensy spider

6.5 crawled up the water spout.

4.5 Down came the rain,

7.5 and washed the spider out.

4.5 Out came the sun

7.5 and dried up all the rain,

5.5 and eensy weensy spider

6.5 crawled up the spout again.

Serial number Title

Lyrics for singer 1

Page 4 of 8

Figure 4 An Album

2.1.4 Lyric Displayer

The Lyric Displayer is a sub-system of the karaoke software System. Its functionality includes

2.1.4.1 Load an Album

To load the contents of an Album. Data of the Album is saved as a text file in your working

directory.

In the file, each song is separated by 3 stars shown in Figure 4.

Figure 4 also indicates the format of the text file to be loaded. The file starts with the name of the

album, and it is followed by songs. Songs are separated by three stars (“***”). The first line of a

Song is its serial number and title. If the Song is a Duet, then the two arrays of Lyrics are separated

by two stars (“**”). Each line of Lyrics contains the displaying time and lyrics.

2.1.4.2 Display the Album

To display the name of the album and all titles of songs for the user to select a song.

Children’s Favourite Songs

***

1 Mary Had a Little Lamb

8.0 Mary had a little lamb,

8.2 Little lamb, little lamb,

8.0 Mary had a little lamb,

9.1 Its fleece was white as snow.

***

2 Twinkle, twinkle, little star

4.4 Twinkle, twinkle, little star

4.2 How I wonder what you are

4.8 Up above the world so high

5.0 Like a diamond in the sky

4.4 Twinkle, twinkle, little star

5.9 How I wonder what you are

***

3 Eensy Weensy Spider

5.5 Eensy weensy spider

6.5 crawled up the water spout.

4.5 Down came the rain,

7.5 and washed the spider out.

4.5 Out came the sun

7.5 and dried up all the rain,

5.5 -

5.5 and eensy weensy spider

6.5 crawled up the spout again.

**

5.5 -

5.5 Eensy weensy spider

6.5 crawled up the water spout.

4.5 Down came the rain,

7.5 and washed the spider out.

4.5 Out came the sun

7.5 and dried up all the rain,

5.5 and eensy weensy spider

6.5 crawled up the spout again.

name of the album

a Solo

a Solo

a Duet

Page 5 of 8

2.1.4.3 Select a Song

To allow the user to select a song. For the selected song, it can perform following actions

(a) Play the Song

To display lyrics (line-by-line) of the song, so that the user(s) can follow it and sing. Note that

while displaying lyrics of a Duet, two lines of lyrics for the second singer may need to be displayed

to fit into the time frame of the first singer.

(b) Delete the Song

To delete the song, so that it is no longer displayed. This action also involves deleting the

song from the Album (ie. the text file) when exiting from the system.

(c) Add a New Song

To add a new song behind the selected song in the Album. For this function, the title and

lyrics of the new Song need to be entered through the keyboard. The serial number should be

generated by the system.

2.1.4.4 Exit

To save the modified Album (i.e. the text file) and exit the system.

2.2 Your Program and Its Execution

Your Lyric Displayer should operate as follows.

2.2.1 Start the program

The program is called with a command line argument. The command line argument is the file name

of the Album (i.e. the name of the text file saved in your working directory).

The program automatically reads contents of the text file and saves the contents into an Album

object. Three assumptions can be made for the text file (i) it does exist in your working directory,

(ii) it is not empty, and (iii) it is in the correct format.

An example of starting the program can be

% java LyricDisplayer childrensFavouriteSongs.txt

Once the Album is loaded, the program displays the list of songs for selection or allows the user to

exit program. After a song is selected, it displays the second menu which includes all possible

actions (such as play, delete and add) for the user to choose.

Samples of menus are shown as Figure 5.

Page 6 of 8

2.3 Data Structures

The Lyric Displayer system contains following classes.

2.3.1 Lyric class

The object of the class contains one line of lyrics (String type), and the time interval in seconds

(double type). Both attributes should be defined as private. The class may include other members

and methods if needed.

2.3.2 Song class

The object of the Song class contains a serial number (int type) and a title (String type). All

should be private. Other attributes and methods can be added if necessary.

2.3.2.1 Solo class

The class inherits the Song class. It has an array of Lyrics objects, which should be defined as

private. Any further members and methods can be added.

2.3.2.2 Duet class

Duet is another class that inherits Song. It contains two arrays of Lyrics objects. All should be

private. Extra members and methods can be defined if needed.

2.3.3 Album class

The object of this class contains the name of the album (String type) and a linked list of Song

objects. Again, all data fields should be declared as private. Add methods whenever you need.

The overview of the data structure is shown in Figure 6

Children’s Favourite Songs

1 Mary Had a Little Lamb

2 Twinkle, Twinkle, Little Star

3 The Eensy Weensy Spider

Enter a number to select a song or type 0 to exit the system: 1

Figure 5 Samples of menus

1. Mary had a Little Lamb

A. Play it

B. Delete it from the menu and the album

C. Add a new song behind it

Select a function:

Page 7 of 8

While completing the assignment, you should define your own linked list. Classes (such as

ArrayList, Arrays, Collections, Dictionary, LinkedList, Stack, Vector and their

derived classes) defined in the java.util package are not allowed in this assignment.

2.4 Program Development

The following is a suggested breakdown for completing this assignment:

Task 1 Class Definition and File Handling

In Task 1, design and implement classes required in this assignment. This includes Lyric, Song, Solo,

Duet and Album. Consider all issues related to handling the text file, such as reading from the file,

separating data, converting data into objects, and finally writing to the file.

Task 2: Driver Class Creation

Design and implement the LyricDisplayer class. This includes all functionality such as play, add and

delete a selected song.

2.5 Coding Style

Correct indention and documentation is a requirement of the assignment. You are required to have

comments for each class to indicate the meaning of each attribute and purpose of each method.

Appropriate comments in the program body are also required.


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp