2010/04/04
End Summer Time
2010/04/02
C# week10_3
31/03/2010
Arraylist in Arraylist
namespace ConsoleApplication9
{
class Program
{
static void Main(string[] args)
{
ArrayList row1 = new ArrayList();
row1.Add("* * ****** * * *** ");
ArrayList row2 = new ArrayList();
row2.Add("* * * * * * * ");
ArrayList row3 = new ArrayList();
row3.Add("****** ****** * * * *");
ArrayList row4 = new ArrayList();
row4.Add("* * * * * * * ");
ArrayList row5 = new ArrayList();
row5.Add("* * ****** ****** ****** *** ");
ArrayList al = new ArrayList();
al.Add(row1);
al.Add(row2);
al.Add(row3);
al.Add(row4);
al.Add(row5);
foreach (ArrayList a in al)
{
IEnumerator ie = a.GetEnumerator();
while (ie.MoveNext())
{
Console.WriteLine(ie.Current.ToString());
}
}
}
}
}
Output
HELLO
One of my class mates wrote "HELL":)
C# week10_2
30/03/2010
Sorting Exam Practice
namespace ConsoleApplication24
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please input increment");
string j = Console.ReadLine();
double inc = double.Parse(j);
Employee.SetIncrement(inc);
ArrayList al = new ArrayList();
int n=0;
do
{
Console.WriteLine("Please input EmployeeID");
string k = Console.ReadLine();
int id = int.Parse(k);
Console.WriteLine("Please input Employee Name");
string name = Console.ReadLine();
Console.WriteLine("Please input Salary");
string l = Console.ReadLine();
double salary = double.Parse(l);
al.Add(new Employee(id, name, salary));
Console.WriteLine("Do you want to enter another Employee? Yes-1 No-0");
string m = Console.ReadLine();
n = int.Parse(m);
}
while (n == 1);
al.Sort(new Sorting());
try
{
FileStream fs = new FileStream
(
@"E:\VirtualExpander_J\C#\Fileaccess\Employeesort.txt",
FileMode.Create,
FileAccess.ReadWrite,
FileShare.Read
);
StreamWriter sw = new StreamWriter(fs);
foreach (Employee m in al)
{
Console.WriteLine(m.GetEID() + " " + m.GetEName() + " " + m.GetNewSalary());
sw.WriteLine(m.GetEID() + " " + m.GetEName() + " " + m.GetNewSalary());
sw.Flush();
}
sw.Close();
fs.Close();
}
catch
{
Console.WriteLine("Try block error");
}
}
}
class Employee
{
int EID;
string EName;
double Salary;
static double Increment=0;
static public void SetIncrement(double d)
{
Increment = d;
}
public int GetEID()
{
return EID;
}
public string GetEName()
{
return EName;
}
public double GetNewSalary()
{
Salary = Salary * (1 + Increment);
return Salary;
//double NewSalary = Salary + (Salary * Increment);
//return NewSalary;
}
public Employee(int id, string name, double salary)
{
EID = id;
EName = name;
Salary = salary;
}
}
class Sorting : IComparer
{
public int Compare(Object a, Object b)
{
Employee em = (Employee)a;
Employee em1 = (Employee)b;
int value = 0;
if (em.GetNewSalary() > em1.GetNewSalary())
{
value = 10;
}
if (em.GetNewSalary() == em1.GetNewSalary())
{
value = 0;
}
if (em.GetNewSalary() < em1.GetNewSalary())
{
value = -10;
}
return value;
}
}
}
Indian culture
ただし、偏った情報かもしれないので、真偽のほどは自己判断でお願いします^^
主に南インドの情報なので、地域によってはかなり異なるかもしれないです。(インドにはいったことないので、わかんないです。)
驚きのインドカルチャー
- 必ず宗教に入っている。入ってないと村で生活できないらしい。
- 割と早く結婚し、女性がお金を出してあげるかわりに女性を守るのが男性の役割だそうです。だから学生中に結婚する人も結構いるらしいです。
- かなりの割合でベジタリアンがいます。全く肉は食べないって言う人から牛肉以外は食べるという人までさまざま。理由は宗教的な理由もあれば、家庭の習慣だったりいろいろみたいです。
- 女性がお酒を飲んだと公の場で公言してはいけないらしい。クラスメイトからびっくりされた^^;インドでは、そんなことを言ってしまったら、生活できなくなるんだよといわれました。
- 全員じゃないけど、朝にはおはようの握手をする人もいます。
- インド人はすごくおしゃべりなイメージがあったんですが、割とみんなシャイです。
- 先生を尊敬する文化だそうなので、先生のことを「Sir」と呼んだりします。
- やっぱり計算が速くて正確。
文化の違いを知るって本当に勉強になる^^
2010/04/01
Would you like to help C# programming?
ぜひ教えてほしいことがあります。
授業で書いたプログラムなのですが、このままコンパイルするとコメントの☆部分が原因でソートできずにランタイムエラーになっちゃいます。
なぜエラーになるのか、もし分かる方がいたら教えてください。
いろいろ調べたものの見つからず。。。。。
もし分かる方がいたら教えてくださいー。
よろしくお願いします!
プログラムの概要
- 3つのクラスで構成
- Employeeクラス
- EmployeeID、Name、Salary の変数
- Salaryが年5%増加と仮定してGetNewSalary()メソッドで新しいサラリーを計算
- IComparerのinheritanceを利用
- ランタイムエラーのコメントは以下のとおりです。
- ハンドルされていない例外: System.ArgumentException: Array.Sort が x. CompareTo(x) を呼び出したときに、IComparer または依存する IComparable メソッドは 0 を返しませんでした。x: 'ConsoleApplication24.Employee' x の型: 'Employee' IComparer: 'ConsoleApplication24.Sorting'
- AnnualIncrementを入力してもらい、Valueを決定
- Employeeオブジェクトを4つ作成しArrayListにインプット
- GetNewSalaryで各自の新しいサラリーを表示(ここまでは表示できます。)
- 新しいサラリーを昇順でソートしてアウトプット(ここでエラー)
namespace ConsoleApplication24
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please input increment");
string j = Console.ReadLine();
double inc = double.Parse(j);
Employee.SetIncrement(inc);
ArrayList al = new ArrayList();
al.Add(new Employee(1, "ABC", 200));
al.Add(new Employee(2, "DEF", 100));
al.Add(new Employee(3, "GHK", 300));
al.Add(new Employee(4, "OPQ", 250));
foreach (Employee n in al)
{
Console.WriteLine(n.GetNewSalary());
} try
{
al.Sort(new Sorting());foreach (Employee m in al)
{
Console.WriteLine(m.GetEID() + " " + m.GetEName() + " " + m.GetNewSalary());
}
}
catch
{
Console.WriteLine("Try block error");
}
}
}
class Employee
{
int EID;
string EName;
double Salary;
public static double Increment = 0;
static public void SetIncrement(double d)
{
Increment = d;
}
public int GetEID()
{
return EID;
}
public string GetEName()
{
return EName;
}
public double GetNewSalary()
{
this.Salary = Salary + (Salary * Increment);
return this.Salary;
//☆この部分がエラー。下の2行に置き換えると問題なく動く。
//double NewSalary = Salary + (Salary * Increment);
//return NewSalary;
}
public Employee(int id, string name, double salary)
{
EID = id;
EName = name;
Salary = salary;
}
}
class Sorting : IComparer
{
public int Compare(Object a, Object b)
{
Employee em = (Employee)a;
Employee em1 = (Employee)b;
double sal = em.GetNewSalary();
double sal1 = em1.GetNewSalary();
int value = 0;
if (sal > sal1)
{
value = 10;
}
else if (sal == sal1)
{
value = 0;
}
else if (sal < sal1)
{
value = -10;
}
return value;
}
}
}
2010/03/30
Data Base week9_4 Extra class
- Name three different programming interfaces that applications programmers can use to process data in each DBMS from external programs written in C++, Java, Visual Basic or other languages.
- For each DBMS, identify and name one query tool supplied with the DBMS and name the language it uses.
- SQL Server and Oracle both provide similar data access tools. Consider an environment where both products are in use. What differences if any would we expect to see in physical database designs between the two products? How would this impact the data management role?
- For each DBMS, name a feature to support distributing read-only data and additionally to support distributing data for updating remotely.
- Describe THREE types of distributed update conflict problem that may occur, and one strategy used to manage this.
- For each DBMS, name two logging and archiving features available to support database recovery and/or audit.
- For each DBMS, describe what option(s) must be chosen to ensure log files are created.
- Describe what implementation strategies would be required to ensure no data is lost in the event of a media failure. Your answer should refer to backup, recovery, audit.
- Describe the options each DBMS has to support concurrent transaction processing. For each option, give the range of values available.
- From your answers to part(i), state the options you would choose for consistent processing in each database if you were required to implement ACID (atomic, consistent, isolated and durable) transactions.
- Describe one consequence to the business of choosing options that fail to guarantee ACID transactions in a multi-user environment.
2010/03/29
C# week10_1
29/03/2010
Sorting
namespace ConsoleApplication23
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter Annual increment");
string a = Console.ReadLine();
int j = int.Parse(a);
Employee.AnnualIncrement=j;
Console.WriteLine(j);
Employee[] e = new Employee[4];
e[0] = new Employee(1, "ABC", 100.00);
e[1] = new Employee(2, "AAA", 200.00);
e[2] = new Employee(3, "XYZ", 500.00);
e[3] = new Employee(4, "CMG", 300.00);
foreach (Employee m in e)
{
Console.WriteLine(m.EmployeeName);
}
Array.Sort(e, new Sorting());
foreach (Employee n in e)
{
Console.WriteLine(n.EmployeeName+ " " + n.Salary + " "+n.GetAnnualIncrement());
}
}
}
class Employee
{
public int EmployeeID;
public string EmployeeName;
public double Salary;
public static int AnnualIncrement;
public double GetAnnualIncrement()
{
double inc = Salary*AnnualIncrement/100;
return inc;
}
public Employee(int id, string name, double salary)
{
EmployeeID =id;
EmployeeName=name;
Salary = salary;
}
}
class Sorting : IComparer
{
public int Compare(object a, object b)
{
Employee em = (Employee)a;
Employee em1 = (Employee)b;
double increment = em.GetAnnualIncrement();
double increment1 = em1.GetAnnualIncrement();
if (increment > increment1)
{
return 10;
}
else
if (increment == increment1)
{
return 0;
}
else
{
return -10;
}
}
}
}
Data Base week9_3
- A common businesses requirement is to limit or deny access to certain types of data. Explain why this is necessary. Refer to data access, security and privacy in your answer.
- Describe two ways using a DBMS can limit access to data. How completely does this meet typical business expectations to control data access, security and privacy?
Business information is rarely for the use of one individual alone. Usually, a range of people in an organization would need to have access to each item of information. So, businesses strive to share access among appropriate groups.- Give one outcome for business risk as shared access grows. What effect does introducing a security policy have on this outcome?
- authorized usersGive one outcome for business performance as shared access grows.
- Give one outcome for database management system performance as shared access grows.
- Give one outcome for business risk as shared access grows. What effect does introducing a security policy have on this outcome?
- Define data integrity. Give one common cause of poor data integrity. Explain why this can present problems to businesses.
- Why does integrating flat file data in a database improve data integrity? Explain why this alone cannot guarantee data integrity.
- Provide one business benefit of integrating data in this way.
- Give three features of DBMS that are designed to improve reliable access to data in the event of system problems or failures. State how these lower the risk of data loss.
- State how these features affect the reliability and risk of the business.
Following are the five tasks performed by database administrators that aid in data management in an organization
| Task | Business impact | Strengths & weaknesses of the ways DBMS support these tasks |
| managing database structure | ||
| controlling concurrent processing | ||
| managing processing rights and responsibilities | ||
| developing database security | ||
| providing for database recovery | ||
| managing the DBMS maintaining the data repository |
2010/03/28
Data Base week9_2
Data Base week9_1
22/03/2010
Exam | Sum up understanding |
Test | Format - NZQA |
Next Test
UML | Question Form | about 5 Classes |
XML | Script - tree diagram | Tree diagram - script |
Draw UML class diagram
2010/03/26
C# week9_3
24/03/2010
Class Program
Making programming by myself
- Random number simple lotto
namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please input number from 0-10");
Random r = new Random();
int j = r.Next(10);
Console.WriteLine(j);
string num = Console.ReadLine();
int i = int.Parse(num);
if (i == j)
{
Console.WriteLine("Frist Match!!");
Console.WriteLine("Please input number from 0-10");
string num1 = Console.ReadLine();
int k = int.Parse(num1);
i = i - 1;
if (i == k)
{
Console.WriteLine("Conglaturations!! You will $1,000.00!!");
}
}
else
{
Console.WriteLine("Do you want to play again? yes-1 no-0");
string num2 = Console.ReadLine();
int l = int.Parse(num2);
while (l == 1)
{
Console.WriteLine("Please input number from 0-10");
string num3 = Console.ReadLine();
int m = int.Parse(num3);
int n = r.Next(10);
if (m == n)
{
Console.WriteLine("Frist Match!!");
Console.WriteLine("Please input number from 0-10");
string num4 = Console.ReadLine();
int o = int.Parse(num4);
m = m - 1;
if (o == m)
{
Console.WriteLine("Conglaturations!! You will $1,000.00!!");
}
}
else
{
Console.WriteLine("Do you want to play again? yes-1 no-0");
string num4 = Console.ReadLine();
int p = int.Parse(num4);
while (p == 1)
{
}
if (p == 0)
{
Console.WriteLine("Good bye");
}
}
}
if (l == 0)
{
Console.WriteLine("Good bye");
}
}
}
}
- Enter 1 Employee data and calculate tax and net salary
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please input Employee ID");
string k = Console.ReadLine();
int id = int.Parse(k);
Console.WriteLine("Please input Employee Name");
string name = Console.ReadLine();
Console.WriteLine("Please input Employee Job");
string job = Console.ReadLine();
Console.WriteLine("Please input Employee Salary");
string j = Console.ReadLine();
double salary = double.Parse(j);
Employee e=new Employee(id,name,job,salary);
int taxrate = e.GetTaxRate();
double tax = e.GetTax();
double netsalary = e.GetNetTax();
Console.WriteLine("Employee Details");
Console.WriteLine("Employee ID:" + id);
Console.WriteLine("Employee Name:" + name);
Console.WriteLine("Employee Job:" + job);
Console.WriteLine("Employee Salary:" + salary);
Console.WriteLine("Employee Tax Rate:" + taxrate+"%");
Console.WriteLine("Employee Tax:" + tax);
Console.WriteLine("Employee Net Salary:" + netsalary);
}
}
class Employee
{
int EmployeeID;
string EmployeeName;
string EmployeeJob;
double Salary;
public int GetTaxRate()
{
int taxrate = 0;
if (Salary < 40000)
{
taxrate = 20;
}
if (40000 <= Salary & Salary < 60000)
{
taxrate = 25;
}
if (60000 <= Salary & Salary < 80000)
{
taxrate = 30;
}
if (80000 <= Salary)
{
taxrate = 40;
}
return taxrate;
}
public double GetTax()
{
double tax = 0;
tax = Salary * GetTaxRate() / 100;
return tax;
}
public double GetNetTax()
{
double nettax = 0;
nettax = Salary - GetTax();
return nettax;
}
public int GetID()
{
return EmployeeID;
}
public string GetName()
{
return EmployeeName;
}
public string GetJob()
{
return EmployeeJob;
}
public double GetSalary()
{
return Salary;
}
public Employee(int id, string name, string job, double salary)
{
EmployeeID = id;
EmployeeName = name;
EmployeeJob = job;
Salary = salary;
}
}
}
- Enter many Employees data and calculate tax and net salary
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
ArrayList employee = new ArrayList();
for (int i = 0; i < 2; i++)
{
Console.WriteLine("Please input Employee ID");
string k = Console.ReadLine();
int id = int.Parse(k);
Console.WriteLine("Please input Employee Name");
string name = Console.ReadLine();
Console.WriteLine("Please input Employee Job");
string job = Console.ReadLine();
Console.WriteLine("Please input Employee Salary");
string j = Console.ReadLine();
double salary = double.Parse(j);
Employee em = new Employee(id, name, job, salary);
employee.Add(em);
}
foreach (Employee e in employee)
{
int id = e.GetID();
string name = e.GetName();
string job = e.GetJob();
double salary = e.GetSalary();
int taxrate = e.GetTaxRate();
double tax = e.GetTax();
double netsalary = e.GetNetTax();
Console.WriteLine("Employee Details");
Console.WriteLine("Employee ID:" + id);
Console.WriteLine("Employee Name:" + name);
Console.WriteLine("Employee Job:" + job);
Console.WriteLine("Employee Salary:" + salary);
Console.WriteLine("Employee Tax Rate:" + taxrate);
Console.WriteLine("Employee Tax:" + tax);
Console.WriteLine("Employee Net Salary:" + netsalary);
}
}
}
class Employee
{
int EmployeeID;
string EmployeeName;
string EmployeeJob;
double Salary;
public int GetTaxRate()
{
int taxrate = 0;
if (Salary < 40000)
{
taxrate = 20;
}
if (40000 <= Salary & Salary < 60000)
{
taxrate = 25;
}
if (60000 <= Salary & Salary < 80000)
{
taxrate = 30;
}
if (80000 <= Salary)
{
taxrate = 40;
}
return taxrate;
}
public double GetTax()
{
double tax = 0;
tax = Salary * GetTaxRate() / 100;
return tax;
}
public double GetNetTax()
{
double nettax = 0;
nettax = Salary - GetTax();
return nettax;
}
public int GetID()
{
return EmployeeID;
}
public string GetName()
{
return EmployeeName;
}
public string GetJob()
{
return EmployeeJob;
}
public double GetSalary()
{
return Salary;
}
public Employee(int id, string name, string job, double salary)
{
EmployeeID = id;
EmployeeName = name;
EmployeeJob = job;
Salary = salary;
}
}
}
C# week9_2
Class Program
- Throw roll die 500 times and count how many times each face is shown
namespace ConsoleApplication22
{
class Program
{
static void Main(string[] args)
{
int counter1 = 0;
int counter2 = 0;
int counter3 = 0;
int counter4 = 0;
int counter5 = 0;
int counter6 = 0;
Random r = new Random();
for (int i = 0; i < 500; i++)
{
int num = r.Next(1,7);
switch(num){
case 1:
counter1++;
break;
case 2:
counter2++;
break;
case 3:
counter3++;
break;
case 4:
counter4++;
break;
case 5:
counter5++;
break;
case 6:
counter6++;
break;
}
}
Console.WriteLine("The sum of 1 face " + counter1);
Console.WriteLine("The sum of 2 face " + counter2);
Console.WriteLine("The sum of 3 face " + counter3);
Console.WriteLine("The sum of 4 face " + counter4);
Console.WriteLine("The sum of 5 face " + counter5);
Console.WriteLine("The sum of 6 face " + counter6);
}
}
}
- Throw roll die 6times and counts sum up them. Repeat this action 500times and count how many times total becomes 10.
namespace ConsoleApplication22
{
class Program
{
static void Main(string[] args)
{
int counter = 0;
Random r = new Random();
for (int i = 0; i < 500; i++)
{
int sum = 0;
for (int j = 0; j < 6; j++)
{
sum = sum+r.Next(1,6);
}
if (sum == 10)
{
counter++;
}
}
Console.WriteLine("The sum of all faces"+counter);
}
}
}
2010/03/25
C# week9_1
22/03/2010
ADO.NET
//Insert, Update, Select SQL command
namespace ConsoleApplication
{
class Program
{
static SqlConnection conn = null;
static void Main(string[] args)
{
SqlDataReader rdr;
try
{
conn = new SqlConnection("Data Source = Server ; Initial Catalog = DBname; Integrated Security = SSPI");
conn.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO CATEGORY VALUES (12, 'Orange')", conn);
cmd.ExecuteNonQuery();
SqlCommand cmd1 = new SqlCommand("UPDATE CATEGORY SET CategoryName='Other' WHERE CategoryID=9", conn);
cmd1.ExecuteNonQuery();
SqlCommand cmd2 = new SqlCommand("SELECT * FROM CATEGORY", conn);
rdr = cmd2.ExecuteReader();
while (rdr.Read())
{
int ID = (int)rdr[0];
string Name = (string)rdr[1];
Console.WriteLine(ID + Name);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
conn.Close();
}
}
}
}
2010/03/22
Amazing at IT English words for me (私が驚いたIT用語?)
私が驚いたキーワードを紹介。エンジニアだったら当たり前だったのかもしれないけど。言葉のニュアンスがカタカナワードとは違う場合があるので難しい。
General
- Decimal 小数点のこと (two decimal places: 小数点第2位)
- Hexadecimal (Base-16) 16進法
- #(hash) ハッシュと読む(イギリス英語だからなのかもしれないけど)
- Numeric 数字の
- Alphabetic アルファベットの
- Upper case 大文字
- Lower case 小文字
- Pen drive USBメモリー
- Dimension 次元(two dimensions: 2次元)
Database
- Normalization 正規化
- Integrity 完全性
- Redundancy 余分なもの(Duplication 重複と同じような意味)
- Assumption 前提条件
- Cursor カーソル(読めなかった。。。)
- Dynamic (辞書だと)動的な
- Static (辞書だと)静的な
- UMLのDynamic DiagramとStatic Diagramを見てなんとなく理解
- Static Diagrams: Class diagram, Physical diagram
- Dynamic Diagrams: Use case diagram, Interaction diagram, State diagram, Activity diagram
- Variable 変数(最初3WeeksぐらいValuableだと思ってたのですごく混乱してた^^;)
- Increment 足し算
- Decrement 引き算
- Polymorphism 多態性(このあたり和訳の限界がある気が。。。)
- Inheritance 継承
- Interface インターフェース(さすがに和訳はあきらめたのか?)
英語うまくなりたいなー^^
2010/03/21
SDI1 week8_1
16/03/2010
UML (Unified Modelling Language)
UML diagrams
Use case diagram
Exam Schedule
Subject | Exam date | Exam time | Exam | Open/Close | Status | Feed Back | Required | Description |
7.403 C# | 13/04 Tue | 01:30-03:40 | Theory Test | Open Book |
| 16/04 2:00 PM | 100P |
|
7.403 C# | 15/04 Thu | 09:00-01:15 | Practical Test | Open Book |
| 19/04 2:00 PM | 100P |
|
7.407 DB | 16/04 Fri | 09:00-01:15 | Practical Test | Close Book |
| 21/04 2:00 PM | 100P |
|
7.407 DB | 20/04 Tue | 01:00-03:10 | Theory Test Part1-A | Close Book |
| 26/04 12:00 PM | 100P |
|
7.407 DB | 22/04 Thu | 09:00-11:10 | Theory Test Part1-B | Close Book |
| 26/04 12:00 PM | 100P |
|
7.408 DB | 19/03 Fri | 09:00-12:15 | Theory & Practical Test Part1 | Close Book | Finish | 23/03 9:00AM | 100P | ERD Anomaly Normalization Integrity |
7.408 DB | 01/04 Thu | 09:00-12:15 | Theory & Practical Test Part2 | Close Book |
| 06/04 9:00 AM | 100P |
|
7.426 SDI1 | 19/04 Mon | 09:00-11:10 | Theory Test | Close Book |
|
| 40P? |
|

