Tuesday, May 28, 2019

Week3 Android Circle

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class Circle {
    double radius;

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }

    public Circle(double radius){
        this.radius = radius;
    }

    public double getArea(){
        return Math.PI * radius * radius;
    }

    public double getCircumference(){
        return 2 * Math.PI * radius;
    }

}

Monday, May 27, 2019

Here are the assignments for All 5 Platforms

You will develop 2 mobile apps:
1) Practice: An app the reads the radius and creates a circle object to calculate the area and circumference of the circle. I will give you an example of this for each chapter.
2) Assignment: An app that reads the length and width and creates a rectangle object to calculate the area and perimeter of the rectangle. Note you will add another textbox (input) control and create a constructor that take two parameters. 
Examples of constructors that take 2 parameters:
JavaScript:
    var myRect = new Rectangle(len,wid);
    //Rectangle.js
    constructor(len,wid)
    {
  this.length=len;
          this.width=wid;
    }
Java:
    Rectangle myRect = new Rectangle(l,w);
    //Rectangle.java
    public Rectangle(double length, double width)
    {
        this.length = length;
        this.width = width;
    }
C#:
    Rectangle myRect = new Rectangle (Double.Parse(etLength.Text),Double.Parse(etWidth.Text) );
    //Rectangle.cs
    public Rectangle (double length, double width)
   {
            this.length  = length;
            this.width  = width;
    }
Swift:
     let myRect=Rectangle(length:len!, width:wid! );
    //Rectangle.swift
     init(length: Double, width: Double) { // Constructor
        self.length= length
        self.width=width        
     }
You will implement the assignments on the following platforms:
  • MIT AppInventor
  • Android and Android studio, language is java.
  • Xamarin and Microsoft Visual Studio. lamguage is C#. 
  • iOS and Xcode , the language is Swift.
  • Cross Platform Web: with a code editor (replit.com is preferred), the language is HTML5, CSS and Javascript.

Week 4: MIT App Inventor (Android)

MIT App Inventor 2
Got an Android phone or tablet? Find out how to Set up and connect an Android device.
Don't have an Android device? Find out how to Set up and run the Android emulator.
How to SMS...
CampusSOS

Tuesday, May 14, 2019

Ch3 Hello help

private void initDisplayButton() {
    Button displayButton = (Button) findViewById(R.id.button);
    displayButton.setOnClickListener(new OnClickListener () {

        @Override        public void onClick(View arg0) {
            EditText editName = (EditText) findViewById(R.id.editText);

            TextView textDisplay = (TextView) findViewById(R.id.textView);
            String nameToDisplay = editName.getText().toString();
            textDisplay.setText("Hello " + nameToDisplay);
        }
    });
}