objective-c IOS代写:COMP282 Assignment 2 – Objective C Programming

COMP282 Assignment 2 –

Objective C Programming

 

·      This assignment involves the creation of a single Objective-C GUI application for Apple Macs, as described below.

 

  • This assignment is worth 50% of the total mark for COMP282

 

 

Submission Instructions

 

  • Make sure your name and student ID number are at the head of each of your source files.
  • Create a .zip file that contains the entire XCode project folder for your solution, as demonstrated in the lab sessions.
  • Submit this zip files using the departmental submission system

 

  • The deadline for this assignment is Monday 14th May, 12 noon

 

  • Penalties for late submission apply in accordance with departmental policy as set out in the student handbook, which can be found at:

http://www.csc.liv.ac.uk/student/ug-handbook.pdf

  • Please note that the new regulations state that late work will be subject to a penalty for each 24-hour period following the submission deadline. This includes weekends!
  • Note also that the markers will assess exactly what you submit. It is up to you to make sure you package your files properly. No attempt will be made by the markers to track down missing files.

 

 

 

The problem

 

Create a Graphical User Interface program for the Mac that will operate as a music player.

The design of the application is entirely up to you, but it should contain the following elements:

  • The name of the artist
  • The title of the album
  • The track currently playing
  • A display which can be switched between:
    • A numbered list of all tracks on the album
    • An image of the album cover
  • A button to switch between the list and cover, as just described
  • A button to go to the next track in sequence
  • A button to go to the previous track in sequence
  • A text box allowing you to type in a track number so that you can go directly to that track
  • A volume slider, with a display to show the current volume (range 0 to 100)
  • A load button, to load a new album

The buttons to move through the tracks should be disabled when appropriate (i.e. when on the first or last track).

(Tip: Set the track number text box so that its action is to ‘Send on enter only’.)

When loading an album, you should present the user with a panel allowing the selection of a file. The file is a simple text file with the following format:

Artist name
Album title
Track 1
Track 2
etc.

To help you in your testing, you have been supplied with a file called sheeran.txt.

TIPS: To allow the user to select a file, declare:

NSOpenPanel *panel = [NSOpenPanel openPanel];

Then run the panel, and check to see if the OK button has been pressed (as opposed to the cancel button):

if ([panel runModal] == NSFileHandlingPanelOKButton) { …}

You can then get the selected filename in the form of a URL:

NSURL *albumURL = [panel URL];

And then the contents of that file as a string:

NSString *info = [NSString stringWithContentsOfURL: albumURL encoding: NSASCIIStringEncoding error: NULL];

Finally, you will need to split up the contents into the respective items. (Hint: take a look at the string message componentsSeparatedByString: )

 

For the album cover image, you may assume that the filename is the same as the text filename, but with the file extension “.jpg” tagged onto the end. Hence, if you load “sheeran.txt”, then “sheeran.txt.jpg” will be brought in for the cover. Again, you have been given the file sheeran.txt.jpg to help you test your code. (500×500 cover images are available on the Amazon web pages for albums).

TIPS:

In the Interface Builder, make your display for track names square, with a side length no larger than 500 pixels. Select an Image View and position it exactly over the track name display. You will need to alter the selected URL to add the “.jpg” extension, then create an NSImage by using:

NSImage *cover = [[NSImage alloc] initWithContentsOfURL: coverURL];

The NSImage can then be loaded into the Image View by using setImage. Switching displays is then simply a case of making the image visible or hidden.

 

 

COMP282 Assignment 2 Marking

 

This assignment is to assess the following learning outcomes:

  • demonstrate the differences in the utilisation of object oriented principles in various C-based programming languages;
  • develop applications using both C++ and Objective-C 2.0 within an industry-level development environment;
  • demonstrate an understanding of the role of design patterns within software development;
  • apply appropriate design patterns when developing event-driven, GUI-based applications, and to utilise of graphical GUI development tools as part of this development.

 

In particular, this assignment tests that you can use Xcode to produce a Graphical User Interface using Objective-C and the Cocoa framework.

Marks will be allocated according to how many of the desired features are implemented, but also for aesthetics and ease of use of the interface, and for qualities of the underlying Objective-C code.

This Assignment contributes 50% towards the total mark for COMP282.