עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

עזרה בתרגיל ב-C#

Featured Replies

פורסם

התרגיל שלי הוא:

Account class: Write a class for "Account". The class will contain the following fields:

The first account number will be 1000, and every new account will get the next number.

For this add a static field to Account class that will hold the last account number so far. Also add a static method that will initialize the field to 1000.

התחלתי לרשום משהו ונתקעתי במתודה שאמורה להחזיק את החשבון האחרון שנפתח ולא ממש בהנתי מה רוצים ממני במתודה האחרונה בתרגיל:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace T295
{
public class Account
{
public int AccountNumber;


//set new account
public void setAccount(int accountNumber)
{
this.AccountNumber = accountNumber;
}


//chech if account number leagal
public bool ifLegal(int accountNumber)
{
if (accountNumber < 1000)
{
return false;
}
else
{
return true;
}
}


//hold the last account number so far
public int LastAccountNumber()
{





}
}


class Program
{
static void Main(string[] args)
{








}
}
}

פורסם

כל הקלאס שלך רחוק מהלהיות מה שהם רוצים.

הם רוצים ככה:

תיצור מחלקה בשם account עם מספר חשבון עוקב.

כדי לעשות את זה הם מבקשים שתיצור שדה סטטי! (static, ככה שהוא לא משתנה בכל יצירה של קלאס->ובכלל בכל התוכנית)

גם כן, מבקשים שתיצור מטודה סטטית שמאתחלת את המשתנה הסטטי ל1000.

וגם מבקשים שכל מחלקה חדשה תהיה עם מספר עוקב ותשתמש במשתנה הסטטי כדי לעקוב(הרי אמרנו שהוא תקף לכל אורך התוכנית ולא מתאפס) (בכל יציאת מחלקה תעשה accountnumber=StaticAccountnumer++;)

אף אחד לא ביקש ממך לבדוק אם מזהה הaccount נכון או לא, אל תוסיף דברים שאין להם סיבת קיום.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.