首页 > > 详细

data留学生作业代写、代做Java课程设计作业、Java编程语言作业调试代写R语言程序|代做R语言编程

Part A – Short answer question (21 x 4 = 84 marks)
Answer these questions in your exam booklet. You should be able to answer these in a few lines.
General comments:
- Some questions are harder than others. You will need to prove you deserve a HD. However, there are
enough easy questions to pass the exam if you have studied a reasonable amount and completed most of
the assignments.
- Some questions ask for simple code segments. Simple syntax errors will be ignored however you must
show the main ideas in the code. You could answer in English but code-ish answers are probably easier.
1. Explain the difference between the heading (similar to compas) and GPS sensors in mobile devices. Give
two examples of apps that could use the heading and two example that could use the GPS sensors. With
your examples, explain how they would use these sensors.
The heading is the compass reading and the GPS is the longitude, latitude and altitude from the worlds GPS
network. (2 marks)
There are thousands of applications that you could mention. The aim hear is to demonstrate your
understanding of the devices.
Some for heading would be a simple compass, car driving assistant, walking assistant. You could mention
combinations, e.g. in co-operation with google maps. (1 mark). Explaining how to use the heading should
be brief, e.g. for a simple compass you just print the heading.
For GPS you could mention driving instructions, aircraft location, height measurement, or walking
instructions. This would work best with a mapping tool. (1 mark) How to use the GPS should be brief, e.g.
driving instruction may just give distance to destination “as the crow flies”.
2. What are the advantages and disadvantages of developing an app in the ionic development environment
over Java (Android) or Objective-C/Swift (iOS)?
Advantages (2 marks):
- Target multi-OS for same source code
- Easier to program
- Re-use web skills
Disadvantages (2 marks)
- Apps larger and slower
- Multiple API’s involved (Typescript, Angualar, Ionic, other Web APIs)
- Lack of support from OS developers (Google, Apple)
3. The following is a JavaScript function header:
function getData(name, studentID) {
… return “”+name+”,”+e-mail; …. }
If the name is a string, the studentID is an integer, and the returned value is a string, how this would be
declared in Typescript to fully specify the types in the function header (Note that we have not always fully
specified function types in the unit).
function getData(name:string, studentID:number) : string
{ … }
Also, how a variable or parameter would be specified that could be assigned as the above functions of its
type.
let f: (n:string, id:number) => string;
Note that variable names can be anything you choose. Some variations in syntax would be fine as long as
you have the main elements (parameters and return types).
4. The following is a TypeScript interface definition:
interface Car {name: string; rego: number; colour?: string};
Which of the following objects is not a correct type? Why?
{name:”Mazda”}
{name:”Mazda”, rego:1234}
{name:”Mazda”, rego:1234, colour:”red”}
{name:”Mazda”, rego:1234, model:”RX-8”}
One mark each:
{name:”Mazda”} no – ‘rego’ is compulsory
{name:”Mazda”, rego:1234} yes
{name:”Mazda”, rego:1234, colour:”red”} yes
{name:”Mazda”, rego:1234, model:”RX-8”} no = ‘model’ not in def
5. What is an injectable service (dependency injection) in Angular? How is an injectable service managed in
a running multi-page app, when each page accesses the service?
(2 marks) – an injectable service is a component that runs independently of the other components. It is
accessed by calling methods on the object that represents the service. You could mention it is a class,
decorated with @Injectable() but not necessary.
(2 mark) – an injectable is managed by the ionic runtime. A component accesses it by declaring it in the
constructor parameters. You could mention it is started when the app starts, configured in the ngmodule
code (app.module.ts) but these are low level details.
6. What is the role of a template in angular? Explain two ways that the typescript code in an app interfaces
with the template.
(2 marks) A template is the HTML specification of the displayed area of a component. It could be a whole
page or part of a page.
(2 marks)
Describe 2 of:
- Interpolation {{xxx }} – display variable value in DOM
- attribute assignment [att]=’xxx’ – adding DOM element attribute to expression
- event handler (tap)=”f()” – assign DIOM event handler to function
- two-way assignment [(xxxx)] – set up two way assignment between DOM variable and component
variable
- *ngif=”xxxx” - only generate DOM if expressions true
- *ngFor=”xxx” – loop expression to generate list or other DOM elements
- *ngSwitch – generate DOM element based on switch values
The description is the main thing. If you said HTML instead of DOM then that is not correct (HTML
generates initial view but DOM maintains dynamic view).
7. The following is an example of an Angular widget definition:

name=”user”/>
From this definition explain:
a) What does this field look like and what does a user do with it?
This is a text field (1 mark).
b) How does the Angular component access the data entered by the user?
The component attribute “userID” has the current value in the text field (1 mark).
c) What is the ‘#userField’ used for and where is it used?
This is a name that is only available in the template code. It can be used anywhere in the template (1 mark).
d) What is the role of the ‘id=”field1”’ attribute?
This links the label to the text field so a user clicking on the label is the same as clicking on the text field (1
mark).
8. Suppose we have an array declared in an Angular component as follows:
name: string;
Using the *ngIf attribute, how would we code a paragraph in the template (using

tags) that displays
the following only if name is an empty string “”:
Name field must be filled.
Solution is:

Name field must be filled


Syntax error is OK but must have *ngIF as attribute with the expression and a paragraph tag (4 marks).
9. Suppose we implement a checkbox in an Angular template as follows:

name="like"/>
What needs to be declared in the component class? Write down the declaration.
(2 marks) We need to declare likeAngular
likeAngular: boolean
Suppose we wanted to use the state of the checkbox answer elsewhere in the template to display one of
the following messages:
User likes Angular: true
Or
User likes Angular: false
How would that be coded in the template?

User likes angular: {{likeAngular}}


You can use another tag, e.g.


联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp2

联系我们 - QQ: 99515681 微信:codinghelp2
© 2014 www.7daixie.com
程序代写网!